Mercurial > logstash
annotate logstash.rc @ 24:0f249d38da21
jruby.spec needs /usr/share to match fedora jrudy location
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 19 Apr 2013 17:48:29 -0700 |
parents | 729f36e68da8 |
children | d058481276aa |
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 | |
24
0f249d38da21
jruby.spec needs /usr/share to match fedora jrudy location
Carl Byington <carl@five-ten-sg.com>
parents:
19
diff
changeset
|
33 JARNAME=/usr/share/java/logstash.jar |
18
2b887e35b5cd
work on building from source
Carl Byington <carl@five-ten-sg.com>
parents:
16
diff
changeset
|
34 ARGS="$JAVAARGS -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 |
19
729f36e68da8
work on building from source
Carl Byington <carl@five-ten-sg.com>
parents:
18
diff
changeset
|
53 $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
|
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 |