Mercurial > logstash
view logstash.rc @ 33:0faebb0b0fa4
update to kibana 3, logstash 1.2.1, es 0.90.5
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 23 Sep 2013 11:50:21 -0700 |
parents | 610835fb4209 |
children | 8ed811f9a0bd |
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 . /etc/sysconfig/logstash export HOME=/var/lib/logstash DESC="Logstash Daemon" JAVA=$(which java 2>/dev/null) CONFIGFILE=/etc/logstash/logstash.conf LOGFILE=/var/log/logstash/logstash.log JARNAME=/usr/share/java/logstash.jar ARGS="$JAVAARGS -jar $JARNAME agent --config $CONFIGFILE --log $LOGFILE $AGENTARGS -- $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 $JAVA $ARGS >&2 & 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