Kibana 4.2 is live and i really love it , but what really annoys me is that why can't be it run as a service like the usual elasticsearch and all which comes with a debian package. Is there a proper way to run it as a service?
You speak as if it's not possible to run it as a daemon which obviously isn't true. It doesn't ship with an init script but writing one shouldn't be hard and if you dig around the GitHub issues you'll find URLs to people who have done it. Also, if you dig out the GitHub issue concerning Debian packaging of Kibana, there's a URL to a complete 4.1.1 Debian package. I've been using it in production for a while and I'd expect the init script and what not to be usable with 4.2. too.
Not yet, we're working on it though so keep your eyes out!
It baffles me why this wasn't part of the launch criteria, especially when the bulk of the work appears to have been completed anyway.
I believe i didn't mean that when i wrote it. Proper way here meant that is there a guidelines as how to do it. Anyways i wrote it myself and it worked Thanks for the help.
I've just spent the day upgrading to ES 2.0 and kibana 4.2.0 (really wanted the black theme )
I found that the init script I previously used for Kibana 4.1.1 did not work for 4.2.0, after lots of changes I think I narrowed it down to the user it runs as, the old script ran the service as "nobody", when I changed this to ubuntu it started up and worked.
When I had the user as "nobody" the "sudo service kibana start" command returned "OK" but didn't actually start up.
Thought I'd mention this in case it helps anyone else out I also changed a couple of log_progress_msg lines to log_daemon_msg as they didn't seem to print either.
This was on Ubuntu 14.04 on EC2 if it helps anyone.
Here's an Init script that I've developed. It runs kibana as a service, and logs it's actions to /var/log/kibana.log in json format so it matches kibana's default output.
This has been tested on Ubuntu 14.04.3 LTS, but it should work on any system that uses modern init.d scripts.
type sudo -i to get root then just copy and paste the entire contents into the terminal.
then type service kibana (start|stop|restart|status|reload). Cheers!
SCRIPT_DIR="/etc/init.d"
SCRIPT_NAME="kibana"
update-rc.d -f "$SCRIPT_NAME" remove && rm "$SCRIPT_DIR/$SCRIPT_NAME"
vim "$SCRIPT_DIR/$SCRIPT_NAME" && chmod +x "$SCRIPT_DIR/$SCRIPT_NAME" && update-rc.d "$SCRIPT_NAME" defaults
:imap kj <Esc>
i#!/bin/bash
#set -x
### BEGIN INIT INFO
#
# Provides: kibana
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Kibana 4.2 init script
# Description: Starts Kibana 4.2 as a daemon.
#
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
## Check to see if we are running as root first.
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
fi
## Kibana 4.2 Init Script.
PROG_NAME="kibana"
PID_PATH="/var/run"
PID_FILE="$PID_PATH/$PROG_NAME"
PROG_PATH="/bin/kibana/bin"
PROG_LOGDIR=/var/log/$PROG_NAME
if ! [ -e "$PROG_LOGDIR" ]; then
mkdir -p $PROG_LOGDIR
fi
start() {
if [ -e "$PID_PATH/$PROG_NAME.pid" ]; then
## Kibana is already running, exit with error.
echo "Error! $PROG_NAME is currently running!" 1>&2
exit 1
else
DATE="$(date '+%FT%T:%:z')"
echo '{"type":"log","@timestamp":"'$DATE'","tags":["start","info"],"pid":$PROG_PID,"message":"Kibana has been started with /etc/init.d/kibana '$PROG_ARGS'"}' >>"$PROG_LOGDIR/$PROG_NAME.log"
exec "$PROG_PATH/$PROG_NAME" >>"$PROG_LOGDIR/$PROG_NAME.log" 2>&1 &
PROG_PID="$!"
printf "$PROG_PID\n" >"$PID_PATH/$PROG_NAME.pid"
echo "$PROG_NAME started with PID: $PROG_PID"
fi
}
stop() {
if [ -e "$PID_PATH/$PROG_NAME.pid" ]; then
## Program is running, so stop it
PROG_PID="$(cat $PID_PATH/$PROG_NAME.pid)"
kill -TERM $PROG_PID
if [ $? == "0" ]; then
rm "$PID_PATH/$PROG_NAME.pid"
DATE="$(date '+%FT%T:%:z')"
echo '{"type":"log","@timestamp":"'$DATE'","tags":["stopped","info"],"pid":$PROG_PID,"message":"Kibana has been stopped with /etc/init.d/kibana '$PROG_ARGS'"}' >>"$PROG_LOGDIR/$PROG_NAME.log"
echo "$PROG_NAME has stopped"
else
echo "Error!: $PROG_NAME has failed to stop! Check PID: $PROG_PID."
exit 1
fi
else
## Program is not running, exit with error.
echo "Error!: $PROG_NAME does not appear to be running!" 1>&2
fi
}
status() {
if [ -e "$PID_PATH/$PROG_NAME.pid" ]; then
PROG_PID="$(cat $PID_PATH/$PROG_NAME.pid)"
ps -l | grep " $PROG_PID " | grep -v grep
if [ $? == "0" ]; then
echo "$PROG_NAME is running with PID: $PROG_PID"
else
ps -aux | grep "$PROG_NAME" | grep -v grep
if [ $? == "0" ]; then
PROG_PID="$(ps -aux | grep "$PROG_NAME" | grep -v grep | awk '{ print $2 }')"
printf "$PROG_PID\n" >"$PID_PATH/$PROG_NAME.pid"
echo "$PROG_NAME is running with PID: $PROG_PID"
else
rm "$PID_PATH/$PROG_NAME.pid"
echo "$PROG_NAME is not running"
fi
fi
else
## Program is not running
echo "$PROG_NAME is not running"
fi
}
case "$1" in
start)
PROG_ARGS="start"
start
exit 0
;;
stop)
PROG_ARGS="stop"
stop
exit 0
;;
status)
PROG_ARGS="status"
status
exit 0
;;
reload)
PROG_ARGS="reload"
stop
start
exit 0
;;
restart)
PROG_ARGS="restart"
stop
start
exit 0
;;
**)
echo "Usage: $0 {start|stop|restart|status|reload}" 1>&2
exit 1
;;
esac
kj
:wq
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.