Skip to content

Instantly share code, notes, and snippets.

@lboynton
Created August 8, 2012 11:09
Show Gist options
  • Select an option

  • Save lboynton/3294316 to your computer and use it in GitHub Desktop.

Select an option

Save lboynton/3294316 to your computer and use it in GitHub Desktop.

Revisions

  1. lboynton renamed this gist Aug 8, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. lboynton created this gist Aug 8, 2012.
    44 changes: 44 additions & 0 deletions graylog2-server
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #!/bin/sh
    #
    # graylog2-server: graylog2 message collector
    #
    # chkconfig: - 98 02
    # description: This daemon listens for syslog and GELF messages and stores them in mongodb
    #
    CMD=$1
    NOHUP=`which nohup`
    JAVA_CMD=/usr/bin/java
    GRAYLOG2_SERVER_HOME=/usr/local/graylog2-server

    start() {
    echo "Starting graylog2-server ..."
    $NOHUP $JAVA_CMD -jar $GRAYLOG2_SERVER_HOME/graylog2-server.jar > /var/log/graylog2.log 2>&1 &
    echo $1 > /tmp/graylog2.pid
    }

    stop() {
    PID=`cat /tmp/graylog2.pid`
    echo "Stopping graylog2-server ($PID) ..."
    kill $PID
    }

    restart() {
    echo "Restarting graylog2-server ..."
    stop
    start
    }

    case "$CMD" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    restart
    ;;
    *)
    echo "Usage $0 {start|stop|restart}"
    RETVAL=1
    esac