Getting started with Upstart

Upstart is an event based monitoring system for monitoring and controlling services and daemons. Upstart is meant to be a replacement for the older System V init.d start up scripts with better optimizations in parrelism and boot time. It can be used to run serveral one off tasks, like that of any shell script, or can monitor long running background services.

To create an upstart script, create a job configuration file in the /etc/init directory. All job configuration files follow the convention of .conf where is the name of the boot script for upstart. Below is a base template of an example upstart script.

1#cooljob.conf
2# my upstart template file
3# This script will start / stop something for me.
4description "Start/stop some service"
5version "1.0"
6author "Chris Zietlow"
7script
8  sleep 1000
9end script

Once an upstart job file is in place it will be available to several upstart commands.

 1start on starting hubot-irc
 2stop on stopping hubot-irc
 3respawn
 4
 5exec su - www-data -c 'cd /home/aczietlow/Web/hubot;
 6export PORT=5000;
 7export HUBOT_IRC_SERVER="irc.freenode.net";
 8export HUBOT_IRC_ROOMS="#spyderbytedesign";
 9export HUBOT_IRC_NICK="kikihubot";
10export HUBOT_IRC_UNFLOOD="true";
11export HUBOT_IRC_PRIVATE="true";
12export FILE_BRAIN_PATH=".";
13bin/hubot --adapter irc >> /var/log/kikibot/hipchat-1.log 2>&1'

Useful commands

  • initctl start | status | stop <script>
    • starts|stops the scripts under
  • initctl list
    • list scripts under /etc/init.d
  • initctl start | status | stop <script>
    • shorthand for initctl start | status | stop
  • initctl log-priority
    • displays the log priority
  • initctl log-priority debug | messages
    • change the messgae priority chkconfig - enable or disable systems services chkconfig --list - check what run levels service is running over
comments powered by Disqus