Launch at Startup

If you have an active public wiki, you might want to ensure that Instiki launches at startup. Under Passenger, Instiki is launched automatically when Apache starts up. If you’re not using Passenger, you’ll need a startup script to launch Instiki.


Under MacOSX 10.4 and later, the launchd dæmon is the preferred method for starting and stopping dæmon processes, such as this one. Here’s a script, which you should save as /Library/LaunchDaemons/instiki.plist .

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
<plist version="1.0">
     <string>Instiki Wiki</string>

Note, as discussed in the Security notes, I created a special, unprivileged, user, ”instiki” under which to run Instiki. Adjust this, and the full path to the instiki executable, accordingly.

Instiki will now automatically launch on startup. You can explictly stop Instiki with

  % sudo launchctl unload /Library/LaunchDaemons/instiki.plist

and restart it with

  % sudo launchctl load /Library/LaunchDaemons/instiki.plist


Dæmons are started by scripts in /etc/init.d . Here’s a suitable script for Instiki.

# instiki     Startup script for the Instiki
# chkconfig: - 85 15
# description: Instiki wiki
# Source function library . /etc/rc.d/init.d/functions
DIR=/usr/local/instiki USER=instiki GROUP=instiki PATH="/sbin:/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" export PATH
PROC="$DIR/instiki --daemon" LOCK=/var/lock/subsys/instiki RETVAL=0
start() { # Check if it is already running if [ ! -f $LOCK ]; then echo -n $"Starting Instiki: " runuser $USER -c "$PROC" RETVAL=$? [ $RETVAL -eq 0 ] && touch $LOCK echo else echo $"Instiki is already running." fi return $RETVAL }
stop() { echo -n $"Stopping Instiki: " kill `cat $DIR/tmp/pids/` RETVAL=$? [ $RETVAL -eq 0 ] && rm -f $LOCK echo return $RETVAL }
restart() { stop sleep 5 start }
case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; condrestart) if [ -f $LOCK ]; then restart fi ;; status) status -p $DIR/tmp/pids/ instiki ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart}" exit 1 esac
exit $RETVAL

As discussed in the Security notes, this script assumes that Instiki will run as a new, unprivileged, user, ”instiki”. Depending on your situation, you may have to customize the DIR, PATH and USER variables.

Save this script as /etc/init.d/instiki and

% sudo chkconfig --add instiki

Instiki will now automatically launch on startup. You can explictly stop Instiki with

% sudo /etc/init.d/instiki stop

and start it with

% sudo /etc/init.d/instiki start