-
-
Save jippi/1065761 to your computer and use it in GitHub Desktop.
Logstash Init script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update-rc.d logstash-shipper defaults | |
update-rc.d logstash-reader defaults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: logstash-shipper | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start daemon at boot time | |
# Description: Enable service provided by daemon. | |
### END INIT INFO | |
. /lib/lsb/init-functions | |
mode="reader" | |
name="logstash-$mode" | |
logstash_bin="/usr/bin/java -- -jar /opt/logstash/logstash.jar" | |
logstash_conf="/etc/logstash/$mode.conf" | |
logstash_log="/var/log/logstash/$name.log" | |
pid_file="/var/run/$name.pid" | |
NICE_LEVEL="-n 19" | |
start () { | |
command="/usr/bin/nice ${NICE_LEVEL} ${logstash_bin} agent -f $logstash_conf --log ${logstash_log}" | |
log_daemon_msg "Starting $mode" "$name" | |
if start-stop-daemon --start --quiet --oknodo --pidfile "$pid_file" -b -m --exec $command; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
} | |
stop () { | |
start-stop-daemon --stop --quiet --oknodo --pidfile "$pid_file" | |
} | |
status () { | |
status_of_proc -p $pid_file "" "$name" | |
} | |
case $1 in | |
start) | |
if status; then exit 0; fi | |
start | |
;; | |
stop) | |
stop | |
;; | |
reload) | |
stop | |
start | |
;; | |
restart) | |
stop | |
start | |
;; | |
status) | |
status && exit 0 || exit $? | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|reload|status}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: logstash-shipper | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start daemon at boot time | |
# Description: Enable service provided by daemon. | |
### END INIT INFO | |
. /lib/lsb/init-functions | |
mode="shipper" | |
name="logstash-$mode" | |
logstash_bin="/usr/bin/java -- -jar /opt/logstash/logstash.jar" | |
logstash_conf="/etc/logstash/$mode.conf" | |
logstash_log="/var/log/logstash/$name.log" | |
pid_file="/var/run/$name.pid" | |
NICE_LEVEL="-n 19" | |
start () { | |
command="/usr/bin/nice ${NICE_LEVEL} ${logstash_bin} agent -f $logstash_conf --log ${logstash_log}" | |
log_daemon_msg "Starting $mode" "$name" | |
if start-stop-daemon --start --quiet --oknodo --pidfile "$pid_file" -b -m --exec $command; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
} | |
stop () { | |
start-stop-daemon --stop --quiet --oknodo --pidfile "$pid_file" | |
} | |
status () { | |
status_of_proc -p $pid_file "" "$name" | |
} | |
case $1 in | |
start) | |
if status; then exit 0; fi | |
start | |
;; | |
stop) | |
stop | |
;; | |
reload) | |
stop | |
start | |
;; | |
restart) | |
stop | |
start | |
;; | |
status) | |
status && exit 0 || exit $? | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|reload|status}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
If you edited the logstash_bin=
line, you may need to make sure that the command is preceded by --
.
logstash_bin="-- /opt/logstash/logstash-1.4.2/bin/logstash"
I got the same error:
- could not access PID file for logstash-shipper
- Starting shipper logstash-shipper
i tried with above soln but still no luck ...plss help
How we make use of multiple pipelines when logstash is running as a service?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First of all, thank you for this gist! It's really helpful. However it's not working for me, and I'm not sure where the problem is. I copied your gist and adjusted the paths. This is the exception I am getting:
Do you have any ideas what could be the problem?