--- title: "实现 INFINI Gateway 配置动态加载" date: 2025-03-16 lastmod: 2025-03-16 description: "本文介绍 Gateway 的动态加载配置功能,无需停机即可更新配置。通过设置 `auto_reload: true`,修改配置后系统自动识别并应用新配置,提升运维效率。" tags: ["Gateway"] summary: "还在停机更新 Gateway 配置,OUT 了。 今天和大家分享一个 Gateway 的功能:动态加载配置(也称热更新或热加载)。 这个功能可以在 Gateway 不停机的情况下更新配置并使之生效。 配置样例如下: path.data: data path.logs: log configs: auto_reload: true # set true to auto reload gateway configurations entry: - name: my_es_entry enabled: true router: my_router max_concurrency: 200000 network: binding: 0.0.0.0:8000 flow: - name: simple_flow filter: - http: schema: https host: 192.168.0.102:9200 router: - name: my_router default_flow: simple_flow 启动 Gateway,配置自动加载开启。 修改配置,如下: path.data: data path.logs: log configs: auto_reload: true # set true to auto reload gateway configurations entry: - name: my_es_entry enabled: true router: my_router max_concurrency: 200000 network: binding: 0." --- 还在停机更新 [Gateway](https://docs.infinilabs.com/gateway/main/) 配置,OUT 了。 今天和大家分享一个 Gateway 的功能:动态加载配置(也称热更新或热加载)。 这个功能可以在 Gateway 不停机的情况下更新配置并使之生效。 配置样例如下: ```yaml path.data: data path.logs: log configs: auto_reload: true # set true to auto reload gateway configurations entry: - name: my_es_entry enabled: true router: my_router max_concurrency: 200000 network: binding: 0.0.0.0:8000 flow: - name: simple_flow filter: - http: schema: https host: 192.168.0.102:9200 router: - name: my_router default_flow: simple_flow ``` 启动 Gateway,配置自动加载开启。 {{% load-img "/img/blog/2025/gateway-auto-reload-config/01.png" "" %}} 修改配置,如下: ```yaml path.data: data path.logs: log configs: auto_reload: true # set true to auto reload gateway configurations entry: - name: my_es_entry enabled: true router: my_router max_concurrency: 200000 network: binding: 0.0.0.0:8000 flow: - name: simple_flow filter: - elasticsearch: elasticsearch: dev router: - name: my_router default_flow: simple_flow elasticsearch: - name: dev enabled: true endpoint: http://localhost:9200 basic_auth: username: test password: testtest ``` 从日志中可以看出修改后的配置文件已经加载。 {{% load-img "/img/blog/2025/gateway-auto-reload-config/02.png" "" %}}