This is my upstart file /etc/init/myapp.conf:

description "Example of starting Node with Upstart and Forever"

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

expect fork

console output

setuid lwood

env HOME=/home/lwood

  cd $HOME
  exec forever -a -l /home/lwood/myapp/applog.log \
       start /home/lwood/myapp/app.js
end script

pre-stop script
  cd $HOME
  exec forever stop /home/lwood/myapp/app.js
end script

Do you know why $ sudo restart myapp is only stopping the service? It does not start the service after stopping it. So it has the same effect as $ sudo stop myapp.

Doing $ sudo stop myapp and then $ sudo start myapp works fine though. Wondering why restarting behaves different.

I'm on Ubuntu 12.04.

1 Answer 1


I would guess it's something to do with the output of the script causing the upstart script to stop.

If you follow the guide on this page they seem to recommend piping the stdout to a log file.

env LOG="/var/log/my-application.log"
exec forever stop /home/lwood/myapp/app.js >> $LOG
  • Thanks for the reply. I tried this but it didn't work. Do you have any other ideas?
    – lwood
    Oct 23, 2013 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.