My application has a self-update feature.
It downloads a new version by itself, and when this occurrs at the end of the download process the JVM exits with code 2.
Is possible to configure the Procrun to auto-restart the service if the exit code 2 occurrs ?
I solved using another tool for running my application as a service: NSSM
With it, I register a parameter to NSSM like this:
So, this lines will:
my-service-namewho launches a copy of my jar (java) application.NSSMto copymy-app.jartosnapshot.jarbefore start the service.NSSMto specify that, when my app terminates the default behavior is assuming that the service must stopNSSMto specify that, when my app terminates with the exit code 2 it must be restarted (my java application) and the service must continue to running.NSSMto specify that my app will using the current directory asc:\path\to\my\appAnother solution is creating a batch file to be on loop, like this (I called it
run-app.bat):And using the NSSM to register the service in a simple way:
In this scenario, the NSSM will just launch my batch
run-app.bat. The batch will stay on loop (restarting my app) while the application exits with code2.