Skip to content

Instantly share code, notes, and snippets.

@fredrick
Created November 22, 2011 18:17
Show Gist options
  • 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
@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