Mosquitto won't start on boot after raspbian and emonsd update

See Install OpenHAB2 on emonSD / emonPi - #34 by pb66 for a working example of a systemd unit that can create the log folder (and file?) if it doesn’t exist when the service is first called, removing the need for an entry in rc.local altogether.

It works the same way the emonhub init script always has but in the form of a service unit.

This approach has worked well for emonhub and can work equally well for all services we maintain or contribute to. But for Redis, Apache2 and Supervisor (which Dataplicity is dependent on) there needs to be another solution and that could be another service unit that doesn’t actually start anything, it simply creates the log folders/files for non-oem softwares and exits.

Instead of adding the paths and owners of the needed log file/folders to rc.local, add it to the logfile creation service unit instead. This new service could be part of the RO changes made to the OS.

I really cannot see why you would want to delay starting the Mosquitto service (or any other service) and rely on something else to create the logfile and start the service afterwards rather than creating the logfile before or at the latest when it is needed. Why add a “wait” or a “sleep” when neither is needed?

What happens if the logfile exists but is the wrong owner or permissions? The service will still try to start and fail, admittedly this is unlikely to happen at boot, but it could happen any other time, for example, what happens if the logfile gets deleted accidentally? even restarting the service won’t fix anything, the user will have to reboot or add it back in manually.

Apache2 and redis etc are beyond our control, but the OEM software’s that are specifically written to be run on an RO OS should be able to create there own logfiles and folders unaided.