<< there's no place like 127.0.0.1

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.

Gitit

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.

Upstart Code

Here is my code for running Gitit with Upstart.

    vim /etc/init/gitit.conf
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 [2345]  
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  

Commands

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:

/var/log/gitit.log

*Note: Be sure to update lines 15 & 16 with your path to the wiki, path to Gitit binary, and your gitit config file.

References

New cPanel and Changing to Paper Lantern Theme

Last night, my servers received the newest cPanel update: version 11.50.0. That’s okay if you’re not following version numbers. Basically...… Continue reading

Installing ImageMagick & PHP Imagick

Published on March 26, 2015

Auto fix for file permissions and ownership

Published on March 15, 2015