We have a project where we're launching jython server processes under supervisord, which expects the pid of the launched process to respond to term signals for the process. With the Jython bash script, however, it executes Java as a subprocess, but if one attempts to terminate the parent process (a bash process), the child java process does not terminate. This means supervisord cannot manage jython processes.
I found that adding 'exec' in the launch of JAVA_CMD (in the jython script) addresses this issue.
I'm guessing that exec can't be added to the script because it will prevent the subsequent code from running.
What is the recommended solution for a case like this? Should we generate the java command line and invoke it directly? Should we patch the jython script with 'exec'? Or should the jython script support a mode where this isn't an issue?
My preference would be for the latter (with perhaps special scripts to handle the cases where invoking java using exec is not desired).
In any case, thanks for the tips.
From: Alan Kennedy <jython-dev@xh...> - 2012-05-02 15:47:20
> We have a project where we’re launching jython server processes under
> supervisord, which expects the pid of the launched process to respond to
> term signals for the process. With the Jython bash script, however, it
> executes Java as a subprocess, but if one attempts to terminate the parent
> process (a bash process), the child java process does not terminate. This
> means supervisord cannot manage jython processes.
A couple of solutions.
1. Supervisord has a new feature where it is able to kill a process
group. In this case, killing the parent bash process would also kill
the child java/jython process.
Not sure if that has been released yet.
2. Modify the jython launcher script script to catch signals and kill
the child process.
Add the following to the script
trap "kill 0" SIGINT SIGTERM EXIT
If you think that the above is a worthwhile feature to add to the
jython launcher script, then please file a bug-report/feature-request
on our bug tracker.
Let us know if either of those solutions works for you.