Certbot (Lets Encrypt) leaves Mosquitto service dead [message #1843238] |
Wed, 21 July 2021 09:27 |
|
I have a real Ubuntu Server hosted in an ISP
It runs a few websites of mine plus a mosquitto broker.
I use certbot from Lets Encypt to autorenew my certificates.
From time to time it renews the mosquitto certs. When it does, it calls this post-hook command:
systemctl restart mosquitto
And my mosquitto service gets left in this state:
kenny@IS-83108:~$ sudo systemctl status mosquitto
* mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated)
Active: active (exited) since Tue 2021-07-20 18:15:11 BST; 15h ago
Docs: man:systemd-sysv-generator(8)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/mosquitto.service
Jul 20 18:15:11 IS-83108 systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Jul 20 18:15:11 IS-83108 mosquitto[22547]: * Starting network daemon: mosquitto
Jul 20 18:15:11 IS-83108 mosquitto[22547]: ...done.
Jul 20 18:15:11 IS-83108 systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
kenny@IS-83108:~$
And the mosquitto log contains this at the tail:
1626801311: mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300) starting
1626801311: Config loaded from /etc/mosquitto/mosquitto.conf.
1626801311: Opening ipv4 listen socket on port 1883.
1626801311: Error: Address already in use
1626801304: New client connected from 188.29.234.133 as 24349eef-a848-4464-81e6-9dceea4bafba (c1, k60).
1626801304: Client 24349eef-a848-4464-81e6-9dceea4bafba disconnected.
1626801311: mosquitto version 1.4.15 terminating
Then I have to manually stop and start the service.
Any ideas?
-Kenny Millar
|
|
|
|
Re: Certbot (Lets Encrypt) leaves Mosquitto service dead [message #1843262 is a reply to message #1843261] |
Wed, 21 July 2021 16:10 |
|
Hi - thanks for the reply!
I managed to work around this issue by editing the mosquitto entry in /etc/init.d
In the "restart" section I added a sleep 2 like this:
restart)
if init_is_upstart; then
exit 1
fi
log_daemon_msg "Restarting network daemon:" "mosquitto"
if start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile ${PIDFILE}; then
rm -f ${PIDFILE}
fi
sleep 2
if start-stop-daemon --start --quiet --oknodo --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} -- -c /etc/mosquitto/mosquitto.conf ; then
log_end_msg 0
else
log_end_msg 1
fi
;;
I'm aware that is a bit of a hack - and is probably not the correct solution. However I will keep looking for a permanent solution and will try upgrading the mosquitto package too.
Thanks again!
-Kenny Millar
|
|
|
Powered by
FUDForum. Page generated in 0.03962 seconds