I'm looking into Apache Daemon to help me with a Java app, and I just wanted to get some ideas/hints about what is possible.
I want to create a simplified application that shows some kind of failsafe ability. The application will go through 4 steps in a sequence (imagine that it prints out to a simple text file in each step just a letter, like step 1 is "A", step 2 is "B" , etc), and I would like to be able to forcibly shutdown the JVM, then have it automatically restart the java application and resume the printing out (imagine it like a child pulling the plug on the TV and it turns on again by itself).
Is this possible to do via Apache Daemon? If so, how would I automate that? Do I need to attach some third-program at the operating-system level (like a simple C program that itself monitors the flow ?).
At this stage I'm just looking for pointers, as I realize it is not really clear what I will do. I prefer Windows, but I do have a Mac also and would be open to using Mac if that is better(I know Linux has some unique tools/abilities ). Any tips/ideas appreciated.
So far, I have tried using this tutorial here for help, which has been useful but not as thorough as I need.
On windows, last time I check it was not managed by procrun (commmons-daemon) but by the windows service management.
You probably need to configure the service recovery after the daemon installation
where %SERVICE_NAME% is ... your service name
the resume logic should be in your application
Edit : add more context
See https://commons.apache.org/proper/commons-daemon/procrun.html for the service installation on windows
when issuing the commands (manually or with a cmd script)
ex :
set SERVICE_NAME=myService
prunsrv //IS//%SERVICE_NAME% --DisplayName="Test Service" \
--Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm \
--StartClass=org.apache.SomeStartClass --StartParams=arg1;arg2;arg3 \
--StopClass=org.apache.SomeStopClass --StopParams=arg1#arg2
add the recovery settings after the service installation
ex
sc failure %SERVICE_NAME% reset= 60 actions= restart/30000
sc failureflag %SERVICE_NAME% 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With