-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
44 lines (34 loc) · 897 Bytes
/
Copy pathdocker-entrypoint.sh
File metadata and controls
44 lines (34 loc) · 897 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
mkdir -p \
"$(dirname "${DB_PATH:-/app/data/db.json}")" \
"${GENERATED_DIR:-/app/generated}" \
"${SECRETS_DIR:-/app/data/secrets}" \
/var/log/apache2 \
/etc/letsencrypt
apache_pid=""
app_pid=""
stop_children() {
if [[ -n "${app_pid}" ]] && kill -0 "${app_pid}" 2>/dev/null; then
kill -TERM "${app_pid}" 2>/dev/null || true
fi
if [[ -n "${apache_pid}" ]] && kill -0 "${apache_pid}" 2>/dev/null; then
apachectl -k graceful-stop 2>/dev/null || kill -TERM "${apache_pid}" 2>/dev/null || true
fi
wait 2>/dev/null || true
}
trap stop_children INT TERM
if [[ "${RUN_APACHE:-true}" == "true" ]]; then
apachectl -DFOREGROUND &
apache_pid="$!"
fi
node /app/server.mjs &
app_pid="$!"
if [[ -n "${apache_pid}" ]]; then
wait -n "${apache_pid}" "${app_pid}"
else
wait "${app_pid}"
fi
status="$?"
stop_children
exit "${status}"