I know I’ve been rather quiet lately. I’ve been busy travelling for a little bit and found myself at a new job. Well, now I’m getting back into the swing of things and wanted to start off with something special.
I started using Gitit wiki this week. I love it, it’s awesome, and I encourage others to check it out. I’ll post a full installation guide soon.
For now, the issue I’m running into is that I want to have Gitit automatically start with the server starts. I also want it to respawn in case the process ever dies. Enter:
I know Ubuntu 15 is implementing systemd, but our servers are still running 14.04 LTS. So, this is relevant to everyone else also on the LTS - or just anyone using upstart :)
Admittedly, I’ve never fully understood init scripts enough to write my own, until now.
Here is my code for running Gitit with Upstart.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 description "Run Gitit service" author "Jacob Tirey - boomshadow.net" start on filesystem or runlevel  stop on runlevel [!2345] respawn respawn limit 10 5 expect daemon script echo $$ > /var/run/gitit-init.pid chdir /path/to/wiki exec /usr/local/bin/gitit -f gitit.conf & end script pre-start script echo "[`date`] Gitit Starting" >> /var/log/gitit.log end script pre-stop script rm /var/run/gitit-init.pid echo "[`date`] Gitit Stopping" >> /var/log/gitit.log end script
That’s it! Now you can start/stop/restart the service like so:
If you restart the server or kill the PID, it’ll auto-restart. You also have logging at:
*Note: Be sure to update lines 15 & 16 with your path to the wiki, path to Gitit binary, and your gitit config file.