You are not logged in.
Hi all,
not sure whether this is the right place to bring up the subject, I would have placed it to admin, but admin is closed :-(
Now here the issue:
Setting up an application that interacts with and depends on mySQL (mariadb) I need to run it as service right from boot. (Home automation with FHEM), while this worked perfectly as long as I had it operating on flat files, it refuses to autostart at boot time using a database, informing me, that no login into mariadb is possible.
After boot, manually starting works OK.
Inserting
After=mariadb.service
Requires=mariadb.service
wouldn't change a thing. While
ExecStartPre=/bin/sh -c "sleep 10"
does the trick
Is this "normal" behaviour or did I miss something here ?
cat /etc/systemd/system/fhem.service
# Modified 20200905 tar after changing FHEM to configDB
[Unit]
Description=FHEM home automation
# After changing from fhem.cfg to configDB FHEM doesn't start on boot.
# After=mariadb.service
# Requires=mariadb.service
# After/Requires mariadb achieves nothing :-(
After=network.target
Requires=network.target
[Service]
# Type=oneshot
# RemainAfterExit=yes
# Oneshot replaced by forking: arch wiki systemd
Type=forking
User=fhem
# Group=Network
# no betterance
WorkingDirectory=/opt/fhem
# ExecStart=/usr/bin/perl fhem.pl fhem.cfg
# Replaced with configDB.
ExecStartPre=/bin/sh -c "sleep 10"
# This does it. mariadb takes too long to get ready.
ExecStart=/usr/bin/perl fhem.pl configDB
ExecStop=/usr/bin/perl fhem.pl 7072 shutdown
Restart=on-abort
[Install]
WantedBy=multi-user.target
Last edited by tchelovek (2020-09-07 02:17:23)
sapere aude
Offline
Sleeping was a solution here: https://forum.fhem.de/index.php/topic,1 … 93434.html
They had a Debmatic service, started with systemd, so the best solution was adding the debmatic service to the 'After' line:
After=network.target debmatic-startupfinished.service
Looks like the sleep is a solution, unless you can narrow down a specific service to list as a dependency that the fhem would work after.
Offline
Sleeping was a solution here: https://forum.fhem.de/index.php/topic,1 … 93434.html
Looks like the sleep is a solution, unless you can narrow down a specific service to list as a dependency that the fhem would work after.
Thanks for your fast reply chaseleif,
as sleeping seems pretty kludgy, I nosed around a little in ARCH provided service files. Their location is published conveniently in the systemctl status message.
I found some hints in
/usr/lib/systemd/system/smb.service
Firstly I learned that multiple arguments can be put in one line.
Secondly they use a target
network-online.target
So I changed my service file as follows:
[Unit]
Description=FHEM - home automation server
Documentation=https://fhem.de/
Documentation=https://fhem.de/commandref.html
Documentation=https://wiki.fhem.de/wiki/Hauptseite
After=network.target network-online.target mariadb.service
Requires=network.target network-online.target mariadb.service
[Service]
Type=forking
User=fhem
WorkingDirectory=/opt/fhem
# ExecStart=/usr/bin/perl fhem.pl fhem.cfg
# Replaced by configDB
ExecStart=/usr/bin/perl fhem.pl configDB
ExecStop=/usr/bin/perl fhem.pl 7072 shutdown
Restart=on-abort
[Install]
WantedBy=multi-user.target
This does the trick for me. I chose Requires over Wants, as it is reportedly somewhat stronger.
sapere aude
Offline