gpt4 book ai didi

elasticsearch - Kubana 4在Ubuntu 12.04中作为服务启动

转载 作者:行者123 更新时间:2023-12-02 22:47:00 24 4
gpt4 key购买 nike

我试图在Ubuntu 12.04中将kibana 4作为服务启动。请任何人帮助设置服务。

我引用了这些链接来编写脚本,但是它不起作用。

https://github.com/akabdog/scripts/blob/master/kibana4_init

https://github.com/chovy/node-startup/blob/master/init.d/node-app

最佳答案

下面的代码为我工作。

#!/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

关于elasticsearch - Kubana 4在Ubuntu 12.04中作为服务启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28939819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com