-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradio_control.sh
More file actions
70 lines (60 loc) · 1.6 KB
/
gradio_control.sh
File metadata and controls
70 lines (60 loc) · 1.6 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
#!/bin/bash
# this is an example gradio control script with some values omitted
cd /datacur/datacur-explore || exit
# Configurations
export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/credentials.json"
PID_FILE="tmp/gradio_app.pid"
SSL_KEYFILE="path/to/your/privkey.pem"
SSL_CERTFILE="path/to/your/fullchain.pem"
APP_COMMAND="python -u main.py --listen=domain --ssl_keyfile=$SSL_KEYFILE --ssl_certfile=$SSL_CERTFILE"
mkdir -p tmp
mkdir -p log
start() {
if [ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") > /dev/null 2>&1; then
echo "Gradio app is already running with PID $(cat $PID_FILE)"
exit 1
fi
echo "Starting Gradio app..."
nohup $APP_COMMAND >> log/gradio_app.log 2>&1 &
echo $! > "$PID_FILE"
echo "Gradio app started with PID $(cat $PID_FILE)"
}
stop() {
if [ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") > /dev/null 2>&1; then
echo "Stopping Gradio app with PID $(cat $PID_FILE)..."
kill $(cat "$PID_FILE") && rm -f "$PID_FILE"
echo "Gradio app stopped."
else
echo "Gradio app is not running."
fi
}
status() {
if [ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") > /dev/null 2>&1; then
echo "Gradio app is running with PID $(cat $PID_FILE)"
else
echo "Gradio app is not running."
fi
}
restart() {
echo "Restarting Gradio app..."
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac