Mercurial > logstash
view logstash.rc @ 15:c158cae7cd26
work on building from source
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 11 Apr 2013 10:18:06 -0700 |
parents | 4899fb1b3eb3 |
children | aa606d801e02 |
line wrap: on
line source
#!/bin/bash # # /etc/rc.d/init.d/logstash # # Starts Logstash as a daemon # # chkconfig: 2345 20 80 # description: Starts Logstash as a daemon # pidfile: /var/run/logstash.pid ### BEGIN INIT INFO # Provides: logstash # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: Logstash # Description: Starts Logstash as a daemon. # Modified originally from https://gist.github.com/2228905#file_logstash.sh ### END INIT INFO # Amount of memory for Java #JAVAMEM=256M . /etc/sysconfig/logstash export HOME=/var/lib/logstash DESC="Logstash Daemon" JAVA=$(which java) CONFIGFILE=/etc/logstash/logstash.conf LOGFILE=/var/log/logstash/logstash.log JARNAME=/usr/local/bin/logstash.jar ARGS="-jar $JARNAME agent --config $CONFIGFILE --log $LOGFILE $AGENTARGS -- web $WEBARGS" PIDFILE=/var/run/logstash.pid base=logstash # Exit if java is not installed if [ ! -x "$JAVA" ]; then echo "Couldn't find java" exit 99 fi . /etc/init.d/functions # # Function that starts the daemon/service # do_start() { cd $HOME pid=$( exec sudo -u logstash /bin/bash - <<EOF export CLASSPATH=/usr/share/jruby.jar:/usr/local/bin/graphtastic-client.jar:/usr/local/bin/elasticsearch.jar $JAVA $ARGS & echo \$! EOF ) echo $pid >$PIDFILE [ -n "$pid" ] && success $"$base startup" || failure $"$base startup" } # # Function that stops the daemon/service # do_stop() { killproc -p $PIDFILE logstash } case "$1" in start) echo -n "Starting $DESC: " do_start touch /var/lock/subsys/$base ;; stop) echo -n "Stopping $DESC: " do_stop rm /var/lock/subsys/$base 2>/dev/null rm $PIDFILE 2>/dev/null ;; restart) echo -n "Restarting $DESC: " do_stop do_start ;; reload) echo -n "Reloading $DESC: " pid=$(cat $PIDFILE) [ -n "$pid" ] && pkill -HUP -u logstash -P $pid ;; status) echo -n "$base " status -p $PIDFILE ;; *) echo "Usage: service $base {start|stop|status|restart}" >&2 exit 3 ;; esac echo exit 0