I\'m using Spring Boot and I\'ve got a use case where user can upload a file which should cause a restart of application (since user\'s upload is used during creation of mul
I have a special case in which my Spring Boot application, which runs on Linux
, is required to run as root
.
Since I run the application as systemd
service, I can restart it like this:
Runtime.getRuntime().exec(new String[] { "/bin/systemctl", "restart", "foo" });
If your application is (hopefully) not required to run as root
, a setuid
wrapper-script could be used, or better, use sudo
.
Check this answer on how to do that:
https://superuser.com/questions/440363/can-i-make-a-script-always-execute-as-root
In your case it might be possible to use the /refresh endpoint (see http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_endpoints) and annotate the beans that depend on the changed configuration with @RefreshScope.
The simplest way to do this by calling the refresh() method on the Spring ApplicationContext. This will kill and reload all of your beans, so you should be certain that this occurs only when it is safe for your application to do so.