Ruin The assorted ramblings of Brendan Tobolaski

Start Ghost using Upstart

I spent some time looking for a script to keep Ghost running. I had 3 things that I wanted to accomplish: to start Ghost on boot, restart Ghost if it dies and to not run Ghost as root. I found a whole bunch that fulfilled the first. A few that fulfilled the first two. The page on deploying Ghost has a few that fulfill the first two. There are way too many that expect you to run Ghost as root, which is not a good idea. Here is the upstart script that I came up with to fulfill all 3 requirements on my Ubuntu server.

description "Ghost Blog"

console output

start on runlevel [2345]
stop on shutdown

respawn limit 99 5
  cd /path/to/ghost
  sudo -u deploy /usr/bin/npm start --production 2>&1
end script

I’m sure, its not great. It probably could be improved. If you know something that could make it better, please leave a comment on the gist