I had an issue where making an upstart script would call the script multiple times, causing my IRCd to spawn around 8 times or so. In order to rectify this, I used start-stop-daemon:
description "IRC Daemon Upstart Script"
start on startup
start on runlevel [2345]
stop on runlevel [016]
respawn
nice -5
exec start-stop-daemon --start --chuid ircuser --chdir /home/ircuser/inspircd/run --exec /home/ircuser/inspircd/run/bin/inspircd -- --config=/home/ircuser/inspircd/run/conf/inspircd.conf
This works exactly like I want it to, EXCEPT that:
stop ircd
says that it stops it, but inspircd is still running afterwards.
Is there a better way than using start-stop-daemon that will stop the script from opening 8 instances, or is there some way I can make it compatible with the start-stop-daemon?
expect fork
fixed the issue. However, I still can't call 'stop ircd' and have the script stop. However, I'll manage without it (ps aux, kill), but if you can amend your answer to include a way to do that, I will be a very happy Ubuntu user ;) – Liam Dawson Dec 21 '11 at 23:28sudo start ircd
it should output a PID. If you stick that on the end ofps
(eg :ps u -p <PID>
) does that show a process that makes sense? If it doesn't it's still losing track of the PID so you might want to tryexpect daemon
– Oli Dec 21 '11 at 23:47ps aux
,kill <pid>
works fine, I was more concerned about making the script START on boot, which it does. Thanks! – Liam Dawson Dec 21 '11 at 23:53