I had already written a basic init.d script for the RedHat server, inspired by a Fedora template. The problem was that it was now catching the other node instance:
The good solution is probably to use a fancy process manager like foreman. Still I wanted to stick to a basic solution. So I decided to go with the `status -p` and `killproc -p` functions (see `/etc/rc.d/init.d/functions`), for the status and stop commands respectively. These function handle our pid file nicely.
But how to get the pid from the daemon function ?
The solution I came up with is to use a subscript that just start the node application and catches the pid:
Here is the whole script:
Now the next enhancement is probably to use a unique parametrized init file, and create links in /etc/init.d to it.