Mercurial > logstash
view logstash.rc @ 35:d5349a22907e default tip
fix license tags in spec files to be fedora compatible
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 25 Sep 2013 21:00:11 -0700 |
parents | 8ed811f9a0bd |
children |
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" 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 </dev/null >/dev/null 2>/dev/null & 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