-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflowgate-web.init
More file actions
80 lines (72 loc) · 1.83 KB
/
flowgate-web.init
File metadata and controls
80 lines (72 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
### BEGIN INIT INFO
# Provides: flowgate-web
# Required-Start: $network $remote_fs flowgate
# Required-Stop: $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Flowgate Web Dashboard
# Description: Web UI for Flowgate management
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=flowgate-web
DESC="Flowgate Web Dashboard"
WORKDIR=/usr/share/flowgate
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/flowgate/flowgate-web.log
USER=flowgate
GROUP=flowgate
. /lib/lsb/init-functions
mkdir -p /var/log/flowgate
chown -R $USER:$GROUP /var/log/flowgate 2>/dev/null || true
do_start() {
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start --quiet --background \
--make-pidfile --pidfile "$PIDFILE" \
--chuid "$USER:$GROUP" \
--chdir "$WORKDIR" \
--startas /bin/sh -- -c "exec /usr/bin/python3 -m uvicorn main:app --host 127.0.0.1 --port 5000 >> $LOGFILE 2>&1"
log_end_msg $?
}
do_stop() {
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --retry=TERM/30/KILL/5
RETVAL=$?
rm -f "$PIDFILE"
log_end_msg $RETVAL
}
do_status() {
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") 2>/dev/null; then
log_success_msg "$NAME is running (PID $(cat $PIDFILE))"
return 0
else
log_failure_msg "$NAME is not running"
return 3
fi
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart)
do_stop
sleep 1
do_start
;;
reload|force-reload)
do_stop
sleep 1
do_start
;;
status)
do_status
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload|status}" >&2
exit 3
;;
esac
exit 0