On Wednesday 05 Oct 2011 18:04:08 Alexander Farber wrote:
My script has 2 pecularities:
- When it gets SIGTERM or SIGINT, it writes some data into PostgreSQL
and this takes 10-15 seconds
- When it is started numerous times,
then the subsequent runs will fail immediately, because only the 1st instance will be able to listen at the TCP-port 8080
And in /var/log/messages I see:
... 17:44:25 static init: pref main process ended, respawning 17:44:26 static init: pref main process (2128) terminated with status 98 17:44:26 static init: pref main process ended, respawning 17:44:26 static init: pref main process (2133) terminated with status 98 17:44:26 static init: pref respawning too fast, stopped
is that all maybe the reason and is there something I could do? (maybe somehow delay the subsequent spawns?)
To solve this problem you can add 'kill timeout 30' to pref.conf, this basically tells upstart that a process may take up to 30 seconds to exit after SIGTERM, and only if it doesn't exit after that it will send SIGKILL.
But as for the issue of why upstart is not picking up the PID correctly, I'm not sure yet. I'm actually dealing with similar issue now so I'll post more when I find something.
BTW, just noticed you're using su -c to run the program. I think this spawns a shell which may be the cause. Could you add 'expect fork' to pref.conf and see if it changes anything?