diff --git a/assets/etc/crontabs/root b/assets/etc/crontabs/root index ed189af..fb82802 100644 --- a/assets/etc/crontabs/root +++ b/assets/etc/crontabs/root @@ -5,4 +5,5 @@ 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 +* * * * * /scripts/haproxy-reload.sh > /proc/$(cat /var/run/supervisord.pid)/fd/1 2>&1 + diff --git a/assets/etc/supervisord.conf b/assets/etc/supervisord.conf index 29e789b..dd1f43b 100644 --- a/assets/etc/supervisord.conf +++ b/assets/etc/supervisord.conf @@ -2,15 +2,15 @@ file=/dev/shm/supervisor.sock ; (the path to the socket file) [supervisord] -logfile=/tmp/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=/tmp/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 ; +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 diff --git a/assets/scripts/certbot.sh b/assets/scripts/certbot.sh index eee72c7..acf9e76 100755 --- a/assets/scripts/certbot.sh +++ b/assets/scripts/certbot.sh @@ -2,6 +2,7 @@ # Semaphore if [ -f /tmp/certbot-lock ]; then + echo "[CERTBOT_JOB] Another process is running" exit 0 fi @@ -25,6 +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" certbot certonly \ --standalone \ --preferred-challenges http \ @@ -39,8 +41,9 @@ if [ -n "$REQUEST_CERTS" ]; then fi if [ -n "$RENEW_CERTS" ]; then + echo "[CERTBOT_JOB] Resquesting renew certificated fort $RENEW_CERTS" certbot renew --post-hook "/scripts/certbot_to_haproxy.sh" fi # Release semaphore -rm /tmp/certbot-lock \ No newline at end of file +rm /tmp/certbot-lock diff --git a/assets/scripts/haproxy-reload.sh b/assets/scripts/haproxy-reload.sh index 61bdba6..ee29cd0 100755 --- a/assets/scripts/haproxy-reload.sh +++ b/assets/scripts/haproxy-reload.sh @@ -35,6 +35,7 @@ else RELOAD="false" else python3 swarm.py > /etc/haproxy/haproxy.cfg + echo "[CONF_CHECK] New configuration found" fi fi @@ -43,19 +44,21 @@ if cmp -s ${CONTROL_FILE} ${CONTROL_FILE}.old ; then fi if [[ ! -z "$1" ]]; then - echo "Initial configuration" + echo "[CONF_CHECK] Initial configuration" RELOAD="false" +else + /scripts/certbot.sh fi -/scripts/certbot.sh # If Certbot reloads successfully will create the file /tmp/force-reload if [ -f /tmp/force-reload ]; then + echo "[CONF_CHECK] New certificates found..." RELOAD="true" rm /tmp/force-reload fi if [[ "$RELOAD" == "true" ]]; then - echo "Reloading..." + echo "[CONF_CHECK] Reloading..." /usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -x /var/run/haproxy.sock -sf $(cat /run/haproxy.pid) & fi