Mercurial > logstash
annotate 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 |
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 | |
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 | 25 export HOME=/var/lib/logstash |
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 | 28 CONFIGFILE=/etc/logstash/logstash.conf |
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 |
34
8ed811f9a0bd
update config files for 1.2.1 syntax changes
Carl Byington <carl@five-ten-sg.com>
parents:
26
diff
changeset
|
31 ARGS="$JAVAARGS -jar $JARNAME agent --config $CONFIGFILE --log $LOGFILE $AGENTARGS" |
0 | 32 PIDFILE=/var/run/logstash.pid |
33 base=logstash | |
34 | |
35 # Exit if java is not installed | |
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 | 38 exit 99 |
39 fi | |
40 | |
41 . /etc/init.d/functions | |
42 | |
43 # | |
44 # Function that starts the daemon/service | |
45 # | |
46 do_start() { | |
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 |
34
8ed811f9a0bd
update config files for 1.2.1 syntax changes
Carl Byington <carl@five-ten-sg.com>
parents:
26
diff
changeset
|
50 $JAVA $ARGS </dev/null >/dev/null 2>/dev/null & |
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 | 54 echo $pid >$PIDFILE |
55 [ -n "$pid" ] && success $"$base startup" || failure $"$base startup" | |
56 } | |
57 | |
58 | |
59 # | |
60 # Function that stops the daemon/service | |
61 # | |
62 do_stop() { | |
63 killproc -p $PIDFILE logstash | |
64 } | |
65 | |
66 | |
67 case "$1" in | |
68 start) | |
69 echo -n "Starting $DESC: " | |
70 do_start | |
71 touch /var/lock/subsys/$base | |
72 ;; | |
73 stop) | |
74 echo -n "Stopping $DESC: " | |
75 do_stop | |
76 rm /var/lock/subsys/$base 2>/dev/null | |
77 rm $PIDFILE 2>/dev/null | |
78 ;; | |
79 restart) | |
80 echo -n "Restarting $DESC: " | |
81 do_stop | |
82 do_start | |
83 ;; | |
84 reload) | |
85 echo -n "Reloading $DESC: " | |
86 pid=$(cat $PIDFILE) | |
87 [ -n "$pid" ] && pkill -HUP -u logstash -P $pid | |
88 ;; | |
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 | 91 status -p $PIDFILE |
92 ;; | |
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 | 95 exit 3 |
96 ;; | |
97 esac | |
98 | |
99 echo | |
100 exit 0 |