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