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: Upstart
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.
description "Run Gitit service"
author "Jacob Tirey - boomshadow.net"
start on filesystem or runlevel 
stop on runlevel [!2345]
respawn limit 10 5
echo $$ > /var/run/gitit-init.pid
exec /usr/local/bin/gitit -f gitit.conf &
echo "[`date`] Gitit Starting" >> /var/log/gitit.log
echo "[`date`] Gitit Stopping" >> /var/log/gitit.log
That's it! Now you can start/stop/restart the service like so:
service gitit start
service gitit stop
service gitit restart
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.