Change systemd unit files to create /var/log/mosquitto

This happens before starting the broker.

Also don't quit with an error if opening the log file isn't possible.

Closes #821.
This commit is contained in:
Roger A. Light 2020-07-14 20:10:54 +01:00
parent abb31ffe8d
commit 5a56f066a8
4 changed files with 10 additions and 3 deletions

View File

@ -2,6 +2,10 @@ Broker:
- Fix usage message only mentioning v3.1.1. Closes #1713.
- Fix broker refusing to start if only websockets listeners were defined.
Closes #1740.
- Change systemd unit files to create /var/log/mosquitto before starting.
Closes #821.
- Don't quit with an error if opening the log file isn't possible.
Closes #821.
Client library:
- Improved documentation around connect callback return codes. Close #1730.

View File

@ -1,5 +1,5 @@
[Unit]
Description=Mosquitto MQTT v3.1/v3.1.1 Broker
Description=Mosquitto MQTT Broker
Documentation=man:mosquitto.conf(5) man:mosquitto(8)
After=network.target
Wants=network.target
@ -10,6 +10,8 @@ NotifyAccess=main
ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto
ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto
[Install]
WantedBy=multi-user.target

View File

@ -1,5 +1,5 @@
[Unit]
Description=Mosquitto MQTT v3.1/v3.1.1 Broker
Description=Mosquitto MQTT Broker
Documentation=man:mosquitto.conf(5) man:mosquitto(8)
After=network.target
Wants=network.target
@ -8,6 +8,8 @@ Wants=network.target
ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto
ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto
[Install]
WantedBy=multi-user.target

View File

@ -114,7 +114,6 @@ int log__init(struct mosquitto__config *config)
log_destinations = MQTT3_LOG_STDERR;
log_priorities = MOSQ_LOG_ERR;
log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open log file %s for writing.", config->log_file);
return MOSQ_ERR_INVAL;
}
restore_privileges();
}