elasticsearch Kibana4在ubuntu 12.04中作为服务启动
我试图在Ubuntu12.04中启动Kibana4作为一项服务。请任何人帮助如何设置为服务 我引用了这些链接来编写脚本,但它不起作用
elasticsearch Kibana4在ubuntu 12.04中作为服务启动,
elasticsearch,logstash,kibana-4,
elasticsearch,Logstash,Kibana 4,我试图在Ubuntu12.04中启动Kibana4作为一项服务。请任何人帮助如何设置为服务 我引用了这些链接来编写脚本,但它不起作用 init脚本中似乎有一个小错误。PID_文件变量使用$NAME变量,但直到稍后才定义名称。将NAME变量移到PID_文件变量之前。初始化脚本中似乎有一个小错误。PID_文件变量使用$NAME变量,但直到稍后才定义名称。将NAME变量移到PID_文件变量之前。下面的代码适用于我 #!/bin/sh KIBANA_EXEC="/opt/kibana/bin/kiban
init脚本中似乎有一个小错误。PID_文件变量使用$NAME变量,但直到稍后才定义名称。将NAME变量移到PID_文件变量之前。初始化脚本中似乎有一个小错误。PID_文件变量使用$NAME变量,但直到稍后才定义名称。将NAME变量移到PID_文件变量之前。下面的代码适用于我
#!/bin/sh
KIBANA_EXEC="/opt/kibana/bin/kibana"
LOG_FILE="/var/log/kibana/.log"
PID_FILE="/var/run/kibana.pid"
PID_DIR="$APP_DIR/pid"
LOG_DIR="$APP_DIR/log"
USAGE="Usage: $0 {start|stop|restart|status} [--force]"
FORCE_OP=false
start_it() {
mkdir -p "$PID_DIR"
mkdir -p "$LOG_DIR"
sleep 10
echo "Starting Kibana..."
$KIBANA_EXEC 1>"$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "Kibana started with pid $!"
}
pid_file_exists() {
[ -f "$PID_FILE" ]
}
get_pid() {
echo "$(cat "$PID_FILE")"
}
is_running() {
PID=$(get_pid)
! [ -z "$(ps aux | awk '{print $2}' | grep "^$PID$")" ]
}
remove_pid_file() {
echo "Removing pid file"
rm -f "$PID_FILE"
}
start_app() {
if pid_file_exists
then
if is_running
then
PID=$(get_pid)
echo "Kibana already running with pid $PID"
exit 1
else
echo "Kibana stopped, but pid file exists"
if [ $FORCE_OP = true ]
then
echo "Forcing start anyways"
remove_pid_file
start_it
fi
fi
else
start_it
fi
}
stop_process() {
PID=$(get_pid)
echo "Killing process $PID"
kill $PID
}
stop_app() {
if pid_file_exists
then
if is_running
then
echo "Stopping kibana ..."
stop_process
remove_pid_file
echo "Kibana stopped"
else
echo "Kibana already stopped, but pid file exists"
if [ $FORCE_OP = true ]
then
echo "Forcing stop anyways ..."
remove_pid_file
echo "Kibana stopped"
else
exit 1
fi
fi
else
echo "Kibana already stopped, pid file does not exist"
exit 1
fi
}
status_app() {
if pid_file_exists
then
if is_running
then
PID=$(get_pid)
echo "Kibana running with pid $PID"
else
echo "Kibana stopped, but pid file exists"
fi
else
echo "Kibana stopped"
fi
}
case "$2" in
--force)
FORCE_OP=true
;;
"")
;;
*)
echo $USAGE
exit 1
;;
esac
case "$1" in
start)
start_app
;;
stop)
stop_app
;;
restart)
stop_app
start_app
;;
status)
status_app
;;
*)
echo $USAGE
exit 1
;;
esac
下面的代码是为我工作
#!/bin/sh
KIBANA_EXEC="/opt/kibana/bin/kibana"
LOG_FILE="/var/log/kibana/.log"
PID_FILE="/var/run/kibana.pid"
PID_DIR="$APP_DIR/pid"
LOG_DIR="$APP_DIR/log"
USAGE="Usage: $0 {start|stop|restart|status} [--force]"
FORCE_OP=false
start_it() {
mkdir -p "$PID_DIR"
mkdir -p "$LOG_DIR"
sleep 10
echo "Starting Kibana..."
$KIBANA_EXEC 1>"$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "Kibana started with pid $!"
}
pid_file_exists() {
[ -f "$PID_FILE" ]
}
get_pid() {
echo "$(cat "$PID_FILE")"
}
is_running() {
PID=$(get_pid)
! [ -z "$(ps aux | awk '{print $2}' | grep "^$PID$")" ]
}
remove_pid_file() {
echo "Removing pid file"
rm -f "$PID_FILE"
}
start_app() {
if pid_file_exists
then
if is_running
then
PID=$(get_pid)
echo "Kibana already running with pid $PID"
exit 1
else
echo "Kibana stopped, but pid file exists"
if [ $FORCE_OP = true ]
then
echo "Forcing start anyways"
remove_pid_file
start_it
fi
fi
else
start_it
fi
}
stop_process() {
PID=$(get_pid)
echo "Killing process $PID"
kill $PID
}
stop_app() {
if pid_file_exists
then
if is_running
then
echo "Stopping kibana ..."
stop_process
remove_pid_file
echo "Kibana stopped"
else
echo "Kibana already stopped, but pid file exists"
if [ $FORCE_OP = true ]
then
echo "Forcing stop anyways ..."
remove_pid_file
echo "Kibana stopped"
else
exit 1
fi
fi
else
echo "Kibana already stopped, pid file does not exist"
exit 1
fi
}
status_app() {
if pid_file_exists
then
if is_running
then
PID=$(get_pid)
echo "Kibana running with pid $PID"
else
echo "Kibana stopped, but pid file exists"
fi
else
echo "Kibana stopped"
fi
}
case "$2" in
--force)
FORCE_OP=true
;;
"")
;;
*)
echo $USAGE
exit 1
;;
esac
case "$1" in
start)
start_app
;;
stop)
stop_app
;;
restart)
stop_app
start_app
;;
status)
status_app
;;
*)
echo $USAGE
exit 1
;;
esac
脚本出现小错误。在日志文件路径中,您需要在末尾指定。log脚本出现小错误。在日志文件路径中,您需要在末尾指定。log您可以比不起作用更具体一些吗?您可以比不起作用更具体一些吗?您可以在我可以将此代码插入的地方向我提供更多信息吗为了在ubuntu中运行kibana as服务,请?在这个主题上我是新手:@cimbom您需要将此代码放在/etc/init.d中才能将其作为服务运行。例如:/etc/init.d/kibana。你能不能提供更多的信息给我,我可以把这段代码插入其中,以便在ubuntu中运行kibana作为服务?在这个主题上我是新手:@cimbom您需要将此代码放在/etc/init.d中才能将其作为服务运行。例如:/etc/init.d/kibana。