[英]How can you dynamically add directories/files (searchLocations) for Spring-Cloud config server to watch?
I am trying to use Spring-Cloud Config to build a configuration server that will allow others apps to register directories/files to be notified of any events (file modification/creation/deletion) that occur. 我正在尝试使用Spring-Cloud Config构建配置服务器,该服务器将允许其他应用程序注册目录/文件,以通知发生的任何事件(文件修改/创建/删除)。
I'm currently limited to storing our configuration files on filesystems, so pointing to a git repo won't work. 我目前仅限于将我们的配置文件存储在文件系统上,因此指向git repo将不起作用。
This is my current applications.properties: 这是我当前的applications.properties:
server.port=8888 spring.profiles.active=native spring.cloud.config.server.native.searchLocations=C:/Users/xxxx/Documents/other/test-config-dir
From what I've researched so far, Spring-Cloud config server points to a location to watch on startup through this application.properties file. 根据到目前为止的研究,Spring-Cloud配置服务器指向了一个通过application.properties文件启动时要监视的位置。 Is there any way for me to add searchLocations without restarting the server?
有什么办法可以在不重新启动服务器的情况下添加searchLocations?
For git repos, I think this would be possible since you can hit endpoints to get configs from branches of said repo right? 对于git repos,我认为这是可能的,因为您可以访问端点以从所述repo的分支获取配置,对吗? But would this even be possible when pointing to a location on the filesystem?
但是,当指向文件系统上的某个位置时,这是否有可能?
The git-based services use hooks to post at a specific endpoint. 基于git的服务使用挂钩在特定端点上发布。 You could use this endpoint (
/monitor
) to trigger the refreshes on your own, for example by sending a request there at regular interval or by implementing a logic that would send that request whenever the file changes - similarly to how github hooks work-. 您可以使用此端点(
/monitor
)自行触发刷新,例如,以固定的时间间隔在那里发送请求,或者通过实现一种在文件更改时都会发送该请求的逻辑-与github钩子的工作方式类似。 You can find more information about setting up the /monitor
enpoint in the Spring Cloud Config Docs in the section "Push Notifications and Spring Cloud Bus". 您可以在“推送通知和Spring Cloud Bus”部分的Spring Cloud Config Docs中找到有关设置
/monitor
更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.