Skip to content

Commit

Permalink
Change systemd unit files to create /var/log/mosquitto
Browse files Browse the repository at this point in the history
This happens before starting the broker.

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

Closes #821.
  • Loading branch information
ralight committed Jul 14, 2020
1 parent abb31ff commit 5a56f06
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion service/systemd/mosquitto.service.notify
@@ -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
Expand All @@ -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
4 changes: 3 additions & 1 deletion service/systemd/mosquitto.service.simple
@@ -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
Expand All @@ -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
1 change: 0 additions & 1 deletion src/logging.c
Expand Up @@ -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();
}
Expand Down

0 comments on commit 5a56f06

Please sign in to comment.