Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ubuntu init script #82

Open
wants to merge 5 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source :rubygems
source 'https://rubygems.org'

gem "compass"
gem "foreman"
Expand Down
68 changes: 45 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,38 +1,60 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
albino (1.3.3)
posix-spawn (>= 0.3.6)
chunky_png (1.2.1)
chunky_png (1.2.9)
classifier (1.3.3)
fast-stemmer (>= 1.0.0)
compass (0.11.5)
colorator (0.1)
commander (4.1.5)
highline (~> 1.6.11)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
directory_watcher (1.4.1)
fast-stemmer (1.0.0)
foreman (0.39.0)
term-ansicolor (~> 1.0.7)
dotenv (0.9.0)
fast-stemmer (1.0.2)
ffi (1.9.3)
foreman (0.63.0)
dotenv (>= 0.7)
thor (>= 0.13.6)
fssm (0.2.7)
haml (3.1.3)
jekyll (0.11.2)
albino (~> 1.3)
fssm (0.2.10)
haml (4.0.4)
tilt
highline (1.6.20)
jekyll (1.3.1)
classifier (~> 1.3)
directory_watcher (~> 1.1)
kramdown (~> 0.13)
liquid (~> 2.3)
maruku (~> 0.5)
kramdown (0.13.5)
liquid (2.3.0)
maruku (0.6.0)
colorator (~> 0.1)
commander (~> 4.1.3)
liquid (~> 2.5.2)
listen (~> 1.3)
maruku (~> 0.6.0)
pygments.rb (~> 0.5.0)
redcarpet (~> 2.3.0)
safe_yaml (~> 0.9.7)
kramdown (1.2.0)
liquid (2.5.4)
listen (1.3.1)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
maruku (0.6.1)
syntax (>= 1.0.0)
posix-spawn (0.3.6)
sass (3.1.7)
pygments.rb (0.5.4)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rb-fsevent (0.9.3)
rb-inotify (0.9.2)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
redcarpet (2.3.0)
safe_yaml (0.9.7)
sass (3.2.12)
syntax (1.0.0)
term-ansicolor (1.0.7)
thor (0.14.6)
thor (0.18.1)
tilt (1.4.1)
yajl-ruby (1.1.0)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
auto: true
# auto: true
title: logstash cookbook
repo: logstash/cookbook
branch: gh-pages
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ to run logstash from the upstart system daemon (comes with Ubuntu).

## [running with init](recipes/using-init/)

Run logstash as a service on your RHEL based system using this init script.
Run logstash as a service on your RHEL/Ubuntu based system using this init script.

## [parsing syslog](recipes/syslog-pri)

Expand Down
7 changes: 6 additions & 1 deletion recipes/using-init/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ tags: init,rhel
---

* Goal: Run the logstash agent as a service using an init script.
* Target audience: Users who have RHEL based servers.
* Target audience: Users who have RHEL / Ubuntu based servers.

# REHL

{% include_code logstash.sh %}

# Ubuntu

{% include_code logstash %}
69 changes: 69 additions & 0 deletions recipes/using-init/logstash
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#! /bin/sh

### BEGIN INIT INFO
# Provides: logstash
# 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

name="logstash"
logstash_bin="/usr/bin/java -- -jar /opt/logstash/logstash-1.2.2-flatjar.jar"
logstash_conf="/etc/logstash/logstash-indexer.conf"
logstash_log="/var/log/$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} -- web"

log_daemon_msg "Starting $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 () {
echo "Stoping $name"
start-stop-daemon --stop --quiet --oknodo --pidfile "$pid_file"
echo "$name stopped"
}

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
Empty file modified regen.sh
100644 → 100755
Empty file.