Kill supervisord
This commit is contained in:
parent
78e9ae3d08
commit
71119268f2
9 changed files with 24 additions and 93 deletions
|
|
@ -1,9 +0,0 @@
|
|||
# do daily/weekly/monthly maintenance
|
||||
# min hour day month weekday command
|
||||
*/15 * * * * run-parts /etc/periodic/15min
|
||||
0 * * * * run-parts /etc/periodic/hourly
|
||||
0 2 * * * run-parts /etc/periodic/daily
|
||||
0 3 * * 6 run-parts /etc/periodic/weekly
|
||||
0 5 1 * * run-parts /etc/periodic/monthly
|
||||
* * * * * /scripts/haproxy-reload.sh > /proc/$(cat /var/run/supervisord.pid)/fd/1 2>&1
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
[unix_http_server]
|
||||
file=/dev/shm/supervisor.sock ; (the path to the socket file)
|
||||
|
||||
[supervisord]
|
||||
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
|
||||
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
|
||||
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
|
||||
loglevel=info ; (log level;default info; others: debug,warn,trace)
|
||||
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
|
||||
nodaemon=false ; (start in foreground if true;default false)
|
||||
minfds=1024 ; (min. avail startup file descriptors;default 1024)
|
||||
minprocs=200 ; (min. avail process descriptors;default 200)
|
||||
user=root ;
|
||||
|
||||
; the below section must remain in the config file for RPC
|
||||
; (supervisorctl/web interface) to work, additional interfaces may be
|
||||
; added by defining them in separate rpcinterface: sections
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///dev/shm/supervisor.sock ; use a unix:// URL for a unix socket
|
||||
|
||||
[program:haproxy]
|
||||
command = /scripts/haproxy.sh
|
||||
autostart=true
|
||||
autorestart=false
|
||||
priority=5
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
[program:crond]
|
||||
command=/usr/sbin/crond -f
|
||||
autostart=true
|
||||
autorestart=false
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
[eventlistener:exit_on_any_fatal]
|
||||
command=/scripts/exit-event-listener.py
|
||||
events=PROCESS_STATE_FATAL,PROCESS_STATE_EXITED,PROCESS_STATE_STOPPED
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Semaphore
|
||||
if [ -f /tmp/certbot-lock ]; then
|
||||
echo "[CERTBOT_JOB] Another process is running"
|
||||
echo "[CERTBOT_JOB] $(date +"$EASYHAPROXY_DATEFORMAT") Another process is running"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ for domain in $(cat /scripts/letsencrypt_hosts.txt); do
|
|||
done
|
||||
|
||||
if [ -n "$REQUEST_CERTS" ]; then
|
||||
echo "[CERTBOT_JOB] Requesting certificates for $REQUEST_CERTS"
|
||||
echo "[CERTBOT_JOB] $(date +"$EASYHAPROXY_DATEFORMAT") Requesting certificates for $REQUEST_CERTS"
|
||||
certbot certonly \
|
||||
--standalone \
|
||||
--preferred-challenges http \
|
||||
|
|
@ -41,7 +41,7 @@ if [ -n "$REQUEST_CERTS" ]; then
|
|||
fi
|
||||
|
||||
if [ -n "$RENEW_CERTS" ]; then
|
||||
echo "[CERTBOT_JOB] Resquesting renew certificated fort $RENEW_CERTS"
|
||||
echo "[CERTBOT_JOB] $(date +"$EASYHAPROXY_DATEFORMAT") Resquesting renew certificated fort $RENEW_CERTS"
|
||||
certbot renew --post-hook "/scripts/certbot_to_haproxy.sh"
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import signal
|
||||
|
||||
from supervisor import childutils
|
||||
|
||||
|
||||
def main():
|
||||
while True:
|
||||
headers, payload = childutils.listener.wait()
|
||||
childutils.listener.ok()
|
||||
events = ['PROCESS_STATE_FATAL', 'PROCESS_STATE_EXITED', 'PROCESS_STATE_STOPPED']
|
||||
if headers['eventname'] not in events:
|
||||
continue
|
||||
|
||||
print(headers)
|
||||
print(payload)
|
||||
os.kill(os.getppid(), signal.SIGTERM)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -35,7 +35,7 @@ else
|
|||
RELOAD="false"
|
||||
else
|
||||
python3 swarm.py > /etc/haproxy/haproxy.cfg
|
||||
echo "[CONF_CHECK] New configuration found"
|
||||
echo "[CONF_CHECK] $(date +"$EASYHAPROXY_DATEFORMAT") New configuration found"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -44,23 +44,23 @@ if cmp -s ${CONTROL_FILE} ${CONTROL_FILE}.old ; then
|
|||
fi
|
||||
|
||||
if [[ ! -z "$1" ]]; then
|
||||
echo "[CONF_CHECK] Initial configuration. Skip certbot."
|
||||
echo "[CONF_CHECK] $(date +"$EASYHAPROXY_DATEFORMAT") Initial configuration. Skip certbot."
|
||||
else
|
||||
/scripts/certbot.sh
|
||||
fi
|
||||
|
||||
# If Certbot reloads successfully will create the file /tmp/force-reload
|
||||
if [ -f /tmp/force-reload ]; then
|
||||
echo "[CONF_CHECK] New certificates found..."
|
||||
echo "[CONF_CHECK] $(date +"$EASYHAPROXY_DATEFORMAT") New certificates found..."
|
||||
RELOAD="true"
|
||||
rm /tmp/force-reload
|
||||
fi
|
||||
|
||||
if [[ ! -z "$1" ]]; then
|
||||
echo "[CONF_CHECK] Starting haproxy..."
|
||||
echo "[CONF_CHECK] $(date +"$EASYHAPROXY_DATEFORMAT") Starting haproxy..."
|
||||
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg $(ls /etc/haproxy/conf.d/*.cfg 2>/dev/null | xargs -I{} echo -f {}) -p /run/haproxy.pid -S /var/run/haproxy.sock &
|
||||
|
||||
elif [[ "$RELOAD" == "true" ]]; then
|
||||
echo "[CONF_CHECK] Reloading..."
|
||||
echo "[CONF_CHECK] $(date +"$EASYHAPROXY_DATEFORMAT") Reloading..."
|
||||
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg $(ls /etc/haproxy/conf.d/*.cfg 2>/dev/null | xargs -I{} echo -f {}) -p /run/haproxy.pid -x /var/run/haproxy.sock -sf $(cat /run/haproxy.pid) &
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -2,8 +2,18 @@
|
|||
|
||||
/usr/sbin/haproxy -v
|
||||
|
||||
source /scripts/haproxy-reload.sh initial
|
||||
if [ -z "$EASYHAPROXY_DATEFORMAT" ]; then
|
||||
export EASYHAPROXY_DATEFORMAT="%Y-%m-%d %H:%M:%S %Z"
|
||||
fi
|
||||
|
||||
if [ -z "$EASYHAPROXY_REFRESH_CONF" ]; then
|
||||
export EASYHAPROXY_REFRESH_CONF=10
|
||||
fi
|
||||
|
||||
/scripts/haproxy-reload.sh initial
|
||||
|
||||
while true; do
|
||||
sleep 60
|
||||
sleep $EASYHAPROXY_REFRESH_CONF
|
||||
echo "[CONF_CHECK] $(date +"$EASYHAPROXY_DATEFORMAT") - Heartbeat."
|
||||
/scripts/haproxy-reload.sh
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue