2022-12-19 04:26:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-02-19 17:33:52 +00:00
|
|
|
# Set up cache size and nameserver subs
|
2023-02-20 16:49:53 +00:00
|
|
|
# Nameservers are taken from /etc/resolv.conf - if the IP contains ":", it's IPv6 and must be enclosed in [] for nginx
|
2022-12-19 04:26:42 +00:00
|
|
|
CACHE_SIZE="${TAKAHE_NGINX_CACHE_SIZE:-1g}"
|
2023-02-20 16:49:53 +00:00
|
|
|
NAMESERVER=`cat /etc/resolv.conf | grep "nameserver" | awk '{print ($2 ~ ":") ? "["$2"]" : $2}' | tr '\n' ' '`
|
2023-02-19 17:33:52 +00:00
|
|
|
if [ -z "$NAMESERVER" ]; then
|
|
|
|
NAMESERVER="9.9.9.9 149.112.112.112"
|
|
|
|
fi
|
|
|
|
sed "s/__CACHESIZE__/${CACHE_SIZE}/g" /etc/nginx/conf.d/default.conf.tpl | sed "s/__NAMESERVER__/${NAMESERVER}/g" > /etc/nginx/conf.d/default.conf
|
2022-12-19 04:26:42 +00:00
|
|
|
|
|
|
|
# Run nginx and gunicorn
|
2023-01-19 05:04:30 +00:00
|
|
|
nginx &
|
2022-12-22 21:28:28 +00:00
|
|
|
|
2022-12-26 17:42:02 +00:00
|
|
|
gunicorn takahe.wsgi:application -b 0.0.0.0:8001 $GUNICORN_EXTRA_CMD_ARGS &
|
2022-12-19 04:26:42 +00:00
|
|
|
|
|
|
|
# Wait for any process to exit
|
|
|
|
wait -n
|
|
|
|
|
|
|
|
# Exit with status of process that exited first
|
|
|
|
exit $?
|