I am having some problems understanding the ideas behind systemd. What I am trying to do is configure a service which should normally run, and that depends on mariadb to work properly. Here is the (anonymized) .service file that I came up with:
[Unit] Description=My Service Requires=mariadb.service After=mariadb.service [Service] ExecStart=/usr/bin/python2.7 -u /home/serviceuser/service.py WorkingDirectory=/home/serviceuser User=serviceuser [Install] WantedBy=multi-user.target
It worked well enough, but I noticed that sometimes the service would spontaneously stop. After some debugging I figured out that this coincided with mariadb security updates being installed automatically by ubuntu. Testing this, I found out that stopping mariadb will stop my service first (which makes sense to me) but starting mariadb back up again will not start my service.
I would expect that the WantedBy means that multi-user.target would really like My Service to run. So systemd should try to ensure that it runs whenever there is nothing that would prevent that. Things that would prevent it would be that the service or one of its dependencies was explicitly stopped. As soon as that preventing condition goes away, systemd should start the service again.
What is the mistake in this reasoning that leads to the service NOT being started again? How can I achieve the behavior I want with systemd?