mosquitto fails to start due to pid file permission errors

Problems with packages? Post here, using [tags] of the package name.

mosquitto fails to start due to pid file permission errors

Postby renkei » Sun Jan 31, 2021 1:52 am

Since the update to mosquitto 2.x I've a lot of trouble to get it started at boot with systemd.

With the 1.6.x release I enabled the pid_file option in /etc/mosquitto/mosquitto.conf and set it to /var/run/mosquitto.pid, as recommend in the documentation of this option. In addtion, I enabled the option user and set it to mosquitto.

This does no longer work for mosquitto 2.x. With the first 2.x release, I got always permission errors, the pid file could not be created. After disabling the pid_file option mosquitto started again with systemd.

But after the latest update, I cannot start mosquitto anymore. There are three different paths mentioned for the pid file:

/run/mosquitto.pid for PIDFile in /etc/systemd/system/multi-user.target.wants/mosquitto.service
/var/run/mosquitto.pid for ExecStartPre in /etc/systemd/system/multi-user.target.wants/mosquitto.service
/var/run/mosquitto/mosquitto.pid for pid_file in /etc/mosquitto/mosquitto.conf

But in the end, I can set all three options to any value, systemd always shows me the error that mosquitto could not be started because the pid file /run/mosquitto.pid could not be created.
renkei
 
Posts: 11
Joined: Sun Jan 31, 2021 1:27 am

Re: mosquitto fails to start due to pid file permission erro

Postby renkei » Sun Jan 31, 2021 10:57 am

I got it working.

In the mosquitto.service file in section [Service] I've added User=mosquitto and changed the ExecStartPre and PIDFile entries to /var/run/mosquitto/mosquitto.pid. Then I've enabled the options

pid_file /var/run/mosquitto/mosquitto.pid
user mosquitto

in the mosquitto.config file. Then I've created the folder /var/run/mosquitto and changed the ownership to mosquitto:mosquitto.

After systemctl daemon-reload and systemctl start mosquitto.service it starts properly again, runs as user mosquitto instead of root and creates the pid file /var/run/mosquitto/mosquitto.pid.

For me, it seems that the PKGBUILD needs some polishment. Propably the same is true on x86_64 and not only related to ArchLinuxARM, haven't tested it yet.
renkei
 
Posts: 11
Joined: Sun Jan 31, 2021 1:27 am


Return to Packages

Who is online

Users browsing this forum: No registered users and 16 guests