简体   繁体   English

如何动态添加目录/文件(searchLocations)以供Spring-Cloud配置服务器观看?

[英]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.

相关问题 spring-cloud如何使用端点 - spring-cloud how to use Endpoints 运行spring-cloud微服务项目,服务器没有启动? - While running spring-cloud microservices project, the server is not starting up? Spring-Cloud配置服务器忽略配置属性文件 - Spring-Cloud configuration server ignores configuration properties file 与netflix Eureka一起使用spring-cloud时,如何让Discovery Client工作? - How can I get the Discovery Client working when using spring-cloud together with netflix Eureka? 如何获取 Spring-Cloud-Config-Server 管理的文件列表 - How to get list of files managed by Spring-Cloud-Config-Server 如何在Spring-Cloud中将ConsulDiscoveryClient与Zuul和Sidecar一起使用 - How do I use the ConsulDiscoveryClient with Zuul and Sidecar in Spring-Cloud Spring Cloud Native Config Server未选择yml文件 - Spring Cloud Native Config Server not picking yml files 如何使用spring-cloud-config服务器将属性注入到现有的xml文件中 - how to using spring-cloud-config server to inject properties into existing xml files spring-cloud 和 spring-cloud-gcp 有通用的 BOM 文件吗? - is there common BOM file for spring-cloud and spring-cloud-gcp? spring-cloud和ribbon可以执行基于DNS的负载平衡吗? - Can spring-cloud and ribbon perform DNS-based load balancing?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM