Mercurial > logstash
annotate logstash.rc @ 3:796ac0b50dbf
add cron.daily index cleaning
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 07 Mar 2013 10:41:01 -0800 |
parents | df4952a2fb06 |
children | 29ffaf4e0a7f |
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 | |
26 export HOME=/var/lib/logstash | |
27 DESC="Logstash Daemon" | |
28 JAVA=$(which java) | |
29 CONFIGFILE=/etc/logstash/logstash.conf | |
30 LOGFILE=/var/log/logstash/logstash.log | |
31 JARNAME=/usr/local/bin/logstash.jar | |
3
796ac0b50dbf
add cron.daily index cleaning
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
32 ARGS="-jar ${JARNAME} agent --config ${CONFIGFILE} --log ${LOGFILE} -- web --backend elasticsearch://127.0.0.1/?local" |
0 | 33 SCRIPTNAME=/etc/rc.d/init.d/logstash |
34 PIDFILE=/var/run/logstash.pid | |
35 base=logstash | |
36 | |
37 # Exit if java is not installed | |
38 if [ ! -x "$JAVA" ]; then | |
39 echo "Couldn't find $JAVA" | |
40 exit 99 | |
41 fi | |
42 | |
43 . /etc/init.d/functions | |
44 | |
45 # | |
46 # Function that starts the daemon/service | |
47 # | |
48 do_start() { | |
49 cd $HOME | |
50 pid=$(su logstash -c 'echo -e "'"$JAVA $ARGS"' </dev/null >'"$LOGFILE"' 2>&1 & \n echo \$!" | bash') | |
51 echo $pid >$PIDFILE | |
52 [ -n "$pid" ] && success $"$base startup" || failure $"$base startup" | |
3
796ac0b50dbf
add cron.daily index cleaning
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
53 # might try |
796ac0b50dbf
add cron.daily index cleaning
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
54 #id |
796ac0b50dbf
add cron.daily index cleaning
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
55 #exec sudo -u transmission /bin/sh - << eof |
796ac0b50dbf
add cron.daily index cleaning
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
56 #id |
796ac0b50dbf
add cron.daily index cleaning
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
57 #eof |
0 | 58 } |
59 | |
60 | |
61 # | |
62 # Function that stops the daemon/service | |
63 # | |
64 do_stop() { | |
65 killproc -p $PIDFILE logstash | |
66 } | |
67 | |
68 | |
69 case "$1" in | |
70 start) | |
71 echo -n "Starting $DESC: " | |
72 do_start | |
73 touch /var/lock/subsys/$base | |
74 ;; | |
75 stop) | |
76 echo -n "Stopping $DESC: " | |
77 do_stop | |
78 rm /var/lock/subsys/$base 2>/dev/null | |
79 rm $PIDFILE 2>/dev/null | |
80 ;; | |
81 restart) | |
82 echo -n "Restarting $DESC: " | |
83 do_stop | |
84 do_start | |
85 ;; | |
86 reload) | |
87 echo -n "Reloading $DESC: " | |
88 pid=$(cat $PIDFILE) | |
89 [ -n "$pid" ] && pkill -HUP -u logstash -P $pid | |
90 ;; | |
91 status) | |
3
796ac0b50dbf
add cron.daily index cleaning
Carl Byington <carl@five-ten-sg.com>
parents:
0
diff
changeset
|
92 echo -n "$base " |
0 | 93 status -p $PIDFILE |
94 ;; | |
95 *) | |
96 echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2 | |
97 exit 3 | |
98 ;; | |
99 esac | |
100 | |
101 echo | |
102 exit 0 |