-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
83 lines (76 loc) · 1.84 KB
/
entrypoint.sh
File metadata and controls
83 lines (76 loc) · 1.84 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
81
82
83
#!/bin/sh
# Use environment variables with defaults
PID_FILE=${GALEPROXY_PID_FILE:-/var/run/galeproxy.pid}
LOG_FILE=${GALEPROXY_LOG_FILE:-/var/log/galeproxy.log}
CONFIG_PATH=${CONFIG_PATH:-/root/config.yaml}
BINARY_PATH=${GALEPROXY_BINARY:-/root/galeproxy}
start() {
if [ -f "$PID_FILE" ]; then
echo "GaleProxy is already running with PID $(cat "$PID_FILE")"
exit 1
fi
echo "Starting GaleProxy..."
nohup "$BINARY_PATH" "$CONFIG_PATH" > "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
sleep 1
if [ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") 2>/dev/null; then
echo "GaleProxy started successfully with PID $(cat "$PID_FILE")"
else
echo "Failed to start GaleProxy. Check logs at $LOG_FILE"
rm -f "$PID_FILE"
exit 1
fi
}
stop() {
if [ ! -f "$PID_FILE" ]; then
echo "GaleProxy is not running"
exit 1
fi
PID=$(cat "$PID_FILE")
echo "Stopping GaleProxy (PID: $PID)..."
kill -TERM "$PID"
sleep 1
if kill -0 "$PID" 2>/dev/null; then
echo "Force stopping GaleProxy..."
kill -KILL "$PID"
fi
rm -f "$PID_FILE"
echo "GaleProxy stopped"
}
restart() {
if [ -f "$PID_FILE" ]; then
stop
sleep 1
fi
start
}
logs() {
if [ -f "$LOG_FILE" ]; then
cat "$LOG_FILE"
else
echo "No logs available yet. Start GaleProxy first."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
logs)
logs
;;
*)
echo "Usage: $0 {start|stop|restart|logs}"
echo " start - Start the GaleProxy service"
echo " stop - Stop the GaleProxy service"
echo " restart - Restart the GaleProxy service"
echo " logs - View GaleProxy logs"
exit 1
;;
esac
exit 0