Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Properties change with out a server restart

I have externalized all my application needed property files from webapps in tomcat. Now i can simply change a property file value without a need of rebuilding the war file and deploy it again. However each change to property file is associated with server recyling.

Is there a way how the recycling can be avoided for a property file change. I am using spring to read the property files for few webapps and java property traditional way for few webapps.

Please suggest how to acheive

like image 862
user2585494 Avatar asked Aug 22 '15 16:08

user2585494


People also ask

Is there a way to change server properties without restarting the server?

Regardless, there's no way to change the server.properties without restarting the server currently, you honestly should not have to change it that often. Instead, take precautions, broadcast to your users "We're making a configuration change, we'll be restarting in 10 seconds", It's not that difficult.

How to reload changes in source code without restarting server?

In spring boot application we can reload source code changes without restarting server.When we develop java application if we do any changes in source code then developer need to application restart and for application up. But in spring boot project we can reload changes in source code without restarting server.

How do I change the value of a property in Spring Boot?

Create a spring boot project and create an endpoint which will read a property from the application.properties file and will return the value in the application.properties file. We will change the value in the application.properties file and we will expect the new value without restarting the server.

Can I change the running value without restarting the SQL Server service?

All of these settings can be modified without restarting the SQL Server service, but some may require you to run RECONFIGURE WITH OVERRIDE to override the running value with the configured value. Configuration options requiring a restart of the SQL Server service are related to database locations and persisted trace flags:


2 Answers

You may want to consider spring-cloud-config-server or spring-cloud-consul all of these options supports distributed properties management as well as value changes refresh without a need to recycle app servers.

And you can use @RefreshScope for Spring @Beans that want to be reinitialized when configuration changes, they also provide the following Management endpoints out of the box and many more as explained on the project git page

  • /refresh for refreshing the @RefreshScope beans
  • /restart for restarting the Spring context (disabled by default)

This is supported by either option (spring-cloud-config-server or spring-cloud-consul)

like image 164
iamiddy Avatar answered Sep 20 '22 07:09

iamiddy


You may also give cfg4j a try. It supports reloading configuration from local files as well as remote services (git repository, Consul, etc.).

like image 35
PanHrabia Avatar answered Sep 23 '22 07:09

PanHrabia