naught
naught copied to clipboard
Naught causing too man fork()'s for Upstart to track
Hi,
I'm consistently seeing Naught run with a PID higher than the one Upstart is trying to track. I have tried both expect fork
and expect daemon
and I am seeing Upstart report start/running, process 3005
but then seeing start_daemon.js
running with a process ID 2 or 3 higher (in this particular case 3007 with expect fork being used).
I'm using Upstart to start my node app with naught when the system boots. I can post my full upstart conf file if it would help.
If I remove the start on
from the conf and therefor have to start the service manually it works the first time but then if I do a service app restart
(or a stop and then a start as separate commands) I end up back on the above pattern.
I appreciate you might not want to get into the vagaries of Upstart but if you have any ideas of what might be causing the behaviour I'm seeing and you can give me a jumping off point I'm happy to do some digging and leg work.
Many thanks for any help or ideas you may have.
I am having this issue too with Ubuntu and using naught as an Upstart service.
I finally messed around and came up with this init daemon script that has been working pretty well for me.
#! /bin/sh
PATH=/home/web/local/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
FLAGS="--expose-gc --nouse-idle-notification --max-new-space-size=2048 --max-old-space-size=14336"
SERVER="/home/web/local/bin/naught"
DAEMON="/home/web/local/bin/node"
SITE="/home/web/code/BuildingBuddy"
NAME=buildingbuddy
DESC="Building Buddy Website"
NAUGHTARGS="--cwd $SITE --worker-count 2 --ipc-file /var/run/buildingbuddy.ipc"
test -x $DAEMON || exit 155
test -x $SERVER || exit 156
set -e
case "$1" in
start)
echo -n "Starting $DESC: \n"
$DAEMON $FLAGS $SERVER start $NAUGHTARGS $SITE/server/app.js
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: \n"
$DAEMON $FLAGS $SERVER stop /var/run/buildingbuddy.ipc
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC: \n"
$DAEMON $FLAGS $SERVER deploy --cwd $SITE --timeout 30 /var/run/buildingbuddy.ipc
echo "$NAME."
;;
status)
$DAEMON $FLAGS $SERVER status /var/run/buildingbuddy.ipc
exit $?
;;
restart|force-reload)
echo -n "Restarting $DESC: \n"
$DAEMON $FLAGS $SERVER deploy --timeout 60 /var/run/buildingbuddy.ipc
if [ $? -ne "0" ]; then
$0 stop
$0 start
exit $?
fi
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Hope it helps.
I think you can just use naught start --daemon-mode false
when running from Upstart, and then don't use either form of expect
. When also changing user, use this bit of magic from the Upstart Cookbook in your script
to avoid excess forks:
exec su -s /bin/sh -c 'exec "$0" "$@"' $user -- ./node_modules/.bin/naught start --daemon-mode false myapp.js