annotate logstash.rc @ 30:f2691b83bafa

update to ES 0.90.0 and logstash 1.1.12
author Carl Byington <carl@five-ten-sg.com>
date Fri, 10 May 2013 15:01:48 -0700
parents 610835fb4209
children 8ed811f9a0bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 #!/bin/bash
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 #
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 # /etc/rc.d/init.d/logstash
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 #
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 # Starts Logstash as a daemon
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 #
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 # chkconfig: 2345 20 80
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 # description: Starts Logstash as a daemon
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 # pidfile: /var/run/logstash.pid
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 ### BEGIN INIT INFO
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 # Provides: logstash
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 # Required-Start: $local_fs $remote_fs
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 # Required-Stop: $local_fs $remote_fs
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 # Default-Start: 2 3 4 5
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 # Default-Stop: S 0 1 6
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 # Short-Description: Logstash
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 # Description: Starts Logstash as a daemon.
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 # Modified originally from https://gist.github.com/2228905#file_logstash.sh
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 ### END INIT INFO
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22
11
4899fb1b3eb3 add sysconfig snippet to avoid modifying non-config files
Carl Byington <carl@five-ten-sg.com>
parents: 7
diff changeset
23 . /etc/sysconfig/logstash
4899fb1b3eb3 add sysconfig snippet to avoid modifying non-config files
Carl Byington <carl@five-ten-sg.com>
parents: 7
diff changeset
24
0
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 export HOME=/var/lib/logstash
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 DESC="Logstash Daemon"
26
610835fb4209 external configuration for kibana
Carl Byington <carl@five-ten-sg.com>
parents: 25
diff changeset
27 JAVA=$(which java 2>/dev/null)
0
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 CONFIGFILE=/etc/logstash/logstash.conf
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 LOGFILE=/var/log/logstash/logstash.log
24
0f249d38da21 jruby.spec needs /usr/share to match fedora jrudy location
Carl Byington <carl@five-ten-sg.com>
parents: 19
diff changeset
30 JARNAME=/usr/share/java/logstash.jar
25
d058481276aa replace logstash embedded web server with kibana
Carl Byington <carl@five-ten-sg.com>
parents: 24
diff changeset
31 ARGS="$JAVAARGS -jar $JARNAME agent --config $CONFIGFILE --log $LOGFILE $AGENTARGS -- $WEBARGS"
0
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 PIDFILE=/var/run/logstash.pid
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 base=logstash
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 # Exit if java is not installed
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 if [ ! -x "$JAVA" ]; then
11
4899fb1b3eb3 add sysconfig snippet to avoid modifying non-config files
Carl Byington <carl@five-ten-sg.com>
parents: 7
diff changeset
37 echo "Couldn't find java"
0
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 exit 99
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 fi
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41 . /etc/init.d/functions
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
42
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
43 #
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
44 # Function that starts the daemon/service
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45 #
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46 do_start() {
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47 cd $HOME
4
29ffaf4e0a7f keep 7 days of data; more readable init script
Carl Byington <carl@five-ten-sg.com>
parents: 3
diff changeset
48 pid=$(
29ffaf4e0a7f keep 7 days of data; more readable init script
Carl Byington <carl@five-ten-sg.com>
parents: 3
diff changeset
49 exec sudo -u logstash /bin/bash - <<EOF
19
729f36e68da8 work on building from source
Carl Byington <carl@five-ten-sg.com>
parents: 18
diff changeset
50 $JAVA $ARGS >&2 &
4
29ffaf4e0a7f keep 7 days of data; more readable init script
Carl Byington <carl@five-ten-sg.com>
parents: 3
diff changeset
51 echo \$!
29ffaf4e0a7f keep 7 days of data; more readable init script
Carl Byington <carl@five-ten-sg.com>
parents: 3
diff changeset
52 EOF
29ffaf4e0a7f keep 7 days of data; more readable init script
Carl Byington <carl@five-ten-sg.com>
parents: 3
diff changeset
53 )
0
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
54 echo $pid >$PIDFILE
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
55 [ -n "$pid" ] && success $"$base startup" || failure $"$base startup"
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
56 }
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
57
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
58
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
59 #
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
60 # Function that stops the daemon/service
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
61 #
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
62 do_stop() {
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63 killproc -p $PIDFILE logstash
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
64 }
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
65
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
66
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
67 case "$1" in
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
68 start)
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
69 echo -n "Starting $DESC: "
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
70 do_start
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
71 touch /var/lock/subsys/$base
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
72 ;;
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
73 stop)
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
74 echo -n "Stopping $DESC: "
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
75 do_stop
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
76 rm /var/lock/subsys/$base 2>/dev/null
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77 rm $PIDFILE 2>/dev/null
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
78 ;;
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
79 restart)
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
80 echo -n "Restarting $DESC: "
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
81 do_stop
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
82 do_start
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
83 ;;
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
84 reload)
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
85 echo -n "Reloading $DESC: "
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
86 pid=$(cat $PIDFILE)
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
87 [ -n "$pid" ] && pkill -HUP -u logstash -P $pid
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
88 ;;
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
89 status)
3
796ac0b50dbf add cron.daily index cleaning
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
90 echo -n "$base "
0
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
91 status -p $PIDFILE
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
92 ;;
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
93 *)
11
4899fb1b3eb3 add sysconfig snippet to avoid modifying non-config files
Carl Byington <carl@five-ten-sg.com>
parents: 7
diff changeset
94 echo "Usage: service $base {start|stop|status|restart}" >&2
0
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
95 exit 3
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
96 ;;
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
97 esac
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
98
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
99 echo
df4952a2fb06 initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
100 exit 0