Skip to content

Instantly share code, notes, and snippets.

@c4milo
Created April 25, 2011 18:05
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save c4milo/940909 to your computer and use it in GitHub Desktop.
Save c4milo/940909 to your computer and use it in GitHub Desktop.
upstart example script
# Ubuntu upstart file at /etc/init/yourservice.conf
pre-start script
mkdir -p /var/log/yourcompany/
end script
respawn
respawn limit 15 5
start on runlevel [2345]
stop on runlevel [06]
script
su - youruser -c "NODE_ENV=test exec /var/www/yourcompany/yourproject/yourservice.js 2>&1" >> /var/log/yourcompany/yourservice.log
end script
@gurre
Copy link

gurre commented Apr 2, 2013

Does it know how to do service yourservice stop?

@mazzzd
Copy link

mazzzd commented Jun 21, 2013

@gurre For service yourservice stop you need write init script instead of upstart script. See the second part of this article.

@shurane
Copy link

shurane commented Apr 28, 2014

@MazzD looks like all you need is pre-stop ... end block for an upstart script, unless I'm missing something?

@jpillora
Copy link

jpillora commented Apr 8, 2015

If you use exec instead of script, it treats it as a single executable and start/stop/loggings works automatically

description "my-prog"

start on runlevel [2345]

exec my-prog foo bar

find logs at /var/log/upstart/my-prog.log

@Tectract
Copy link

how to include restart command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment