Skip to content

Instantly share code, notes, and snippets.

@fredrick
Created November 22, 2011 18:17
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredrick/1386421 to your computer and use it in GitHub Desktop.
Save fredrick/1386421 to your computer and use it in GitHub Desktop.
Graylog2 Upstart Jobs

#Graylog2 Upstart

A basic set of Upstart jobs to get Graylog2 up and running quickly. Assumes MongoDB and Graylog2 installed in /opt/. Tested on Ubuntu Server 10.04 LTS, MongoDB 2.0.0, graylog2-server-0.9.5p1, and graylog2-web-interface-0.9.5p2.

#Usage

Place job definitions in /etc/init/ and then use service [job] [command] to start/stop/restart/status the services manually. On boot, the services flow into each other, only starting if dependent services have started. For more on controlling jobs or Upstart in general (a replacement for System-V init), see the cookbook.

#Author

Fredrick Galoso

# Upstart file at /etc/init/graylog2-server.conf
# Graylog2 Server
start on started mongodb
stop on [06]
expect fork
script
cd /opt/graylog2-server
exec sudo java -jar graylog2-server.jar &
emit graylog2-server_running
end script
# Upstart file at /etc/init/graylog2-web.conf
# Graylog2 Web Interface
start on started graylog2-server
stop on [06]
expect fork
script
cd /opt/graylog2-web-interface
exec script/rails server -e production &
emit graylog2-web_running
end script
# Upstart file at /etc/init/mongodb.conf
# MongoDB
limit nofile 20000 20000
kill timeout 300 # wait 300s between SIGTERM and SIGKILL.
pre-start script
mkdir -p /opt/mongo/data/
mkdir -p /opt/mongo/log/
end script
start on runlevel [2345]
stop on runlevel [06]
script
ENABLE_MONGODB="yes"
if [ -f /etc/default/mongodb ]; then . /etc/default/mongodb; fi
if [ "x$ENABLE_MONGODB" = "xyes" ]; then exec start-stop-daemon --start --quiet --chuid mongodb --exec /opt/mongo/bin/mongod -- --config /etc/mongodb.conf; fi
end script
@smith
Copy link

smith commented Nov 23, 2011

Nice work on this. It's going in my cookbook (https://github.com/cramerdev/cookbooks/blob/master/graylog2/) I like Supervisor for some jobs, but you wouldn't believe how hard it is to find good initscripts these days.

@fredrick
Copy link
Author

Thanks and glad I can help. Wrapping my head around and actually learning Upstart was long on my bucket list so I killed two birds with one stone in using it to run Graylog2.

@notslang
Copy link

notslang commented Sep 1, 2012

Thank you very much for writing this. I ended up not using the one for MongoDB because the default installation directory was different and Mongo comes with its own upstart script. However, the other 2 seem to work perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment