I'm trying to refactor a single systemd service/program into multiple programs and services. My single big service looked like:
[Unit] Description=Runs the App loop After=network-online.target [Service] Type=simple ExecStart=/usr/bin/python3 -u /App/mainLoop WorkingDirectory=/App StandardOutput=journal Restart=on-failure [Install] WantedBy=multi-user.target
I cobbled this together from other examples. What I want now is two services:
[Unit] Description=Initializes some things After=network-online.target # Question 1 [Service] Type=simple ExecStart=/usr/bin/python3 -u /App/startup WorkingDirectory=/App StandardOutput=journal Restart=on-failure # Question 2 [Install] WantedBy=multi-user.target
[Unit] Description=Runs the App loop After=network-online.target # Question 3 [Service] Type=simple ExecStart=/usr/bin/python3 -u /App/mainLoop WorkingDirectory=/App StandardOutput=journal Restart=on-failure [Install] WantedBy=multi-user.target # Question 4
So I have multiple question points here (referenced by the comments above):
- I don't need the network to be alive anymore for this. What should I put here instead? How does one browse possible targets?
- I want the startup app to just run once at startup, never again. I assume I need to change the
Restartflag to something else, but what?
- Rather than after the network of course, I want this to run after service A completes AND ONLY IF it managed to exit with a 0 and write a file. How do I make it start after the one time service A starts successfully?
- More of 3 I guess. I'm still fuzzy on what the difference is between the
WantedBytarget and the
Aftertarget. Is the
WantedBybasically the group it belongs to, and the
Afterthe one that it has to be serialized after?