We have a jboss application server running a webapp. We need to implement a "restart" button somewhere in the UI that causes the entire application server to restart. Our naive implementation was to call our /etc/init.d script with the restart command. This shuts down our application server then restarts it.
However, it appears that when the java process shuts down, the child process running the restart scripts dies as well, before getting to the point in the script where it starts the app server again.
We tried variations on adding '&' to the places where scripts are called, but that didn't help. Is there some where to fire the script and die without killing the script process?
-
Try using the
nohupcommand to run something from within the script that you execute via Java. That is, if the script that you execute from Java currently runs this:/etc/init.d/myservice restartthen change it to do this:
nohup /etc/init.d/myservice restartAlso, ensure that you DO NOT have stdin, stdout, or stderr being intercepted by the Java process. This could cause problems, potentially. Thus, maybe try this (assuming bash or sh):
nohup /etc/init.d/myservice restart >/dev/null 2>&1 -
Set your signal handlers in the restart script to ignore your signal with trap:
trap "" 2 # ignore SIGINT trap "" 15 # ignore SIGTERMAfter doing this, you'll need to kill your restart script with some other signal when needed, probably SIGKILL.
0 comments:
Post a Comment