view Kibana.rc @ 29:b37cde5bac95

switch kibana to ruby gem rather than jruby
author Carl Byington <carl@five-ten-sg.com>
date Tue, 07 May 2013 11:03:17 -0700
parents 76544ad0561d
children
line wrap: on
line source

#!/bin/bash
#
#	/etc/rc.d/init.d/Kibana
#
#	Starts Kibana as a daemon
#
# chkconfig: 2345 20 80
# description: Starts Kibana as a daemon
# pidfile: /var/run/Kibana.pid

### BEGIN INIT INFO
# Provides: Kibana
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Kibana
# Description: Starts Kibana as a daemon.

### END INIT INFO

. /etc/sysconfig/Kibana

DESC="Kibana Daemon"
LOGFILE=/var/log/Kibana/Kibana.log
PIDFILE=/var/run/Kibana.pid
base=Kibana

. /etc/init.d/functions

#
# Function that starts the daemon/service
#
do_start() {
    cd /home/kibana
    pid=$(
    exec sudo -u kibana /bin/bash - <<EOF
        export KIBANA_HOST=$KIBANA_HOST
        export KIBANA_PORT=$KIBANA_PORT
        export KIBANA_ES=$KIBANA_ES
        export KIBANA_CONFIG=$KIBANA_CONFIG
        kibana >>$LOGFILE 2>&1 &
        echo \$!
EOF
    )
    echo $pid >$PIDFILE
    [ -n "$pid" ] && success $"$base startup" || failure $"$base startup"
}


#
# Function that stops the daemon/service
#
do_stop() {
    killproc -p $PIDFILE Kibana
}


case "$1" in
  start)
    echo -n "Starting $DESC: "
    do_start
    touch /var/lock/subsys/$base
    ;;
  stop)
    echo -n "Stopping $DESC: "
    do_stop
    rm /var/lock/subsys/$base 2>/dev/null
    rm $PIDFILE               2>/dev/null
    ;;
  restart)
    echo -n "Restarting $DESC: "
    do_stop
    do_start
    ;;
  reload)
    echo -n "Reloading $DESC: "
    pid=$(cat $PIDFILE)
    [ -n "$pid" ] && pkill -HUP -u Kibana -P $pid
    ;;
  status)
    echo -n "$base "
    status -p $PIDFILE
    ;;
  *)
    echo "Usage: service $base {start|stop|status|restart}" >&2
    exit 3
    ;;
esac

echo
exit 0