I
I
Igor Kvitko2014-08-23 17:19:13
Node.js
Igor Kvitko, 2014-08-23 17:19:13

Why is Upstart not running node js?

Good afternoon.
There was a problem setting up a file under node js to run in the background. The problem is that when the process starts, the system writes that it has started it, but in fact it just stops it.
The contents of the node.conf file

description "node.js server"
author "rdbn"

env NODE_BIN=/usr/local/bin/node
env APP_DIR=/home/rdbn/game
env SCRIPT_FILE="app.js" # Entry point for the nodejs app
env LOG_FILE=/var/log/node.sys.log
env RUN_AS="rdbn"

start on filesystem or runlevel [2345]
stop on [!2345]

#start on (local-filesystems and net-device-up IFACE=eth0)
#stop on shutdown

script
        touch $LOG_FILE
        chown $RUN_AS:$RUN_AS $LOG_FILE
        chdir $APP_DIR
        exec sudo -u $RUN_AS sh -c " $NODE_BIN $SCRIPT_FILE >> $LOG_FILE 2>&1"
end script

pre-start script
        echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> $LOG_FILE
end script

pre-stop script
        echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> $LOG_FILE
end script

respawn
respawn limit 5 30

On start/stop/status:
sudo start node
node start/running, process 2015

sudo stop node
stop: Unknown instance:

sudo status node
node stop/waiting

PS help me figure it out, I'm setting it up for the first time and I apologize for earlier if something is wrong.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Krasnodemsky, 2014-08-23
@Prognosticator

Use pm2 , it starts without config .

M
MasMaX, 2015-08-10
@MasMaX

Maybe it's in the title of the task? Change node.conf to game.conf (by application name).
Plus, look at the /var/log/syslog logs - there may be a reason for the failure to start. Well, or read your log - /var/log/node.sys.log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question