-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathentrypoint.sh
More file actions
56 lines (45 loc) · 1.36 KB
/
Copy pathentrypoint.sh
File metadata and controls
56 lines (45 loc) · 1.36 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
#!/bin/sh
set -eu
: "${WXWEBHOOK_SERVER_ADDR:=127.0.0.1:18731}"
: "${WXWEBHOOK_DATA_DIR:=/data}"
: "${WXWEBHOOK_DB_PATH:=/data/wxwebhook.db}"
export WXWEBHOOK_SERVER_ADDR
export WXWEBHOOK_DATA_DIR
export WXWEBHOOK_DB_PATH
mkdir -p "${WXWEBHOOK_DATA_DIR}" \
/run/nginx \
/tmp/nginx/client_temp \
/tmp/nginx/proxy_temp \
/tmp/nginx/fastcgi_temp \
/tmp/nginx/uwsgi_temp \
/tmp/nginx/scgi_temp
# Optional convenience: derive CORS origin from a single external variable.
if [ -n "${PUBLIC_ORIGIN:-}" ] && [ -z "${WXWEBHOOK_PANEL_ORIGIN:-}" ]; then
export WXWEBHOOK_PANEL_ORIGIN="${PUBLIC_ORIGIN}"
fi
/usr/local/bin/wxwebhook-core &
CORE_PID=$!
nginx -g "daemon off;" &
NGINX_PID=$!
shutdown() {
kill -TERM "${CORE_PID}" 2>/dev/null || true
kill -TERM "${NGINX_PID}" 2>/dev/null || true
wait "${CORE_PID}" 2>/dev/null || true
wait "${NGINX_PID}" 2>/dev/null || true
}
trap shutdown INT TERM
while true; do
if ! kill -0 "${CORE_PID}" 2>/dev/null; then
wait "${CORE_PID}" || true
kill -TERM "${NGINX_PID}" 2>/dev/null || true
wait "${NGINX_PID}" 2>/dev/null || true
exit 1
fi
if ! kill -0 "${NGINX_PID}" 2>/dev/null; then
wait "${NGINX_PID}" || true
kill -TERM "${CORE_PID}" 2>/dev/null || true
wait "${CORE_PID}" 2>/dev/null || true
exit 1
fi
sleep 1
done