Switched to original server implementation & included server shim
This commit is contained in:
96
V3.1/build/etc/init.d/S04jibo-asr-service
Executable file
96
V3.1/build/etc/init.d/S04jibo-asr-service
Executable file
@@ -0,0 +1,96 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Minimal init.d script to start jibo-asr-service at boot.
|
||||
# Matches requested command exactly:
|
||||
# /usr/local/bin/jibo-asr-service -c /usr/local/etc/jibo-asr-service.json
|
||||
|
||||
DAEMON="/usr/local/bin/jibo-asr-service"
|
||||
CONFIG="/usr/local/etc/jibo-asr-service.json"
|
||||
PIDFILE="/var/run/jibo-asr-service.pid"
|
||||
LOGFILE="/tmp/jibo-asr-service.log"
|
||||
|
||||
is_running() {
|
||||
# Prefer pidof if present
|
||||
if command -v pidof >/dev/null 2>&1; then
|
||||
pidof jibo-asr-service >/dev/null 2>&1 && return 0
|
||||
fi
|
||||
# Fall back to pidfile check
|
||||
if [ -f "$PIDFILE" ]; then
|
||||
PID="$(cat "$PIDFILE" 2>/dev/null)"
|
||||
[ -n "$PID" ] && kill -0 "$PID" >/dev/null 2>&1 && return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
do_start() {
|
||||
if [ ! -x "$DAEMON" ]; then
|
||||
echo "jibo-asr-service: missing $DAEMON" >&2
|
||||
return 0
|
||||
fi
|
||||
if [ ! -f "$CONFIG" ]; then
|
||||
echo "jibo-asr-service: missing $CONFIG" >&2
|
||||
# still try to run; daemon may have defaults
|
||||
fi
|
||||
if is_running; then
|
||||
echo "jibo-asr-service: already running"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Starting jibo-asr-service..."
|
||||
"$DAEMON" -c "$CONFIG" >>"$LOGFILE" 2>&1 &
|
||||
PID=$!
|
||||
echo "$PID" >"$PIDFILE" 2>/dev/null || true
|
||||
return 0
|
||||
}
|
||||
|
||||
do_stop() {
|
||||
if ! is_running; then
|
||||
echo "jibo-asr-service: not running"
|
||||
rm -f "$PIDFILE" 2>/dev/null || true
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Stopping jibo-asr-service..."
|
||||
if [ -f "$PIDFILE" ]; then
|
||||
PID="$(cat "$PIDFILE" 2>/dev/null)"
|
||||
if [ -n "$PID" ]; then
|
||||
kill "$PID" >/dev/null 2>&1 || true
|
||||
sleep 1
|
||||
kill -9 "$PID" >/dev/null 2>&1 || true
|
||||
fi
|
||||
else
|
||||
# Best-effort without pidfile
|
||||
if command -v killall >/dev/null 2>&1; then
|
||||
killall jibo-asr-service >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
rm -f "$PIDFILE" 2>/dev/null || true
|
||||
return 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
do_start
|
||||
;;
|
||||
stop)
|
||||
do_stop
|
||||
;;
|
||||
restart|force-reload)
|
||||
do_stop
|
||||
do_start
|
||||
;;
|
||||
status)
|
||||
if is_running; then
|
||||
echo "jibo-asr-service: running"
|
||||
exit 0
|
||||
fi
|
||||
echo "jibo-asr-service: stopped"
|
||||
exit 3
|
||||
;;
|
||||
*)
|
||||
# default: start when called without args
|
||||
do_start
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user