6
votes

I made some custom systemd services long time ago, all have the same configuration (except for the ExecStart of course)

This configuration worked for years, I have ubuntu up and running since version 18.04 LTS, but now looks like some of these systemd services aren't starting at boot at all, the configuration is as follow (myapp.service):

[Unit]
Description="myapp"
After=syslog.target network-online.target
Wants=network-online.target

[Service]
Restart=always
RestartSec=10
User=root
Group=root
WorkingDirectory=/opt/myapp
ExecStart=/usr/local/bin/myapp
KillMode=control-group

[Install]
WantedBy=multi-user.target

The service is enabled:

$ sudo systemctl enable myapp
Created symlink /etc/systemd/system/multi-user.target.wants/myapp.service → /lib/systemd/system/myapp.service.

If i do "systemctl status myapp" after a reboot:

● myapp.service - "myapp"
   Loaded: loaded (/lib/systemd/system/myapp.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

If i do "journalctl -u myapp -f" after a reboot:

Jan 13 12:10:06 myhost systemd[1]: Started myapp.
Jan 17 07:15:03 myhost systemd[1]: Stopping myapp...
Jan 17 07:15:09 myhost systemd[1]: Stopped myapp.

What's wrong with my configuration?

If I manually start /usr/local/bin/myapp there are no errors on the script and I've also tried running it with tmux, now it's 3 days running in bg and no errors. But systemd just won't start it after a reboot.

Today, i've also tried to install a new service that require a systemd config, the package is zram-config and by default it is enabled at boot. But after a: apt install zram-config && sudo reboot:

$ sudo systemctl status zram-config
● zram-config.service - Initializes zram swaping
   Loaded: loaded (/lib/systemd/system/zram-config.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

but if now i do:

$ sudo systemctl start zram-config
$ sudo systemctl status zram-config
● zram-config.service - Initializes zram swaping
   Loaded: loaded (/lib/systemd/system/zram-config.service; enabled; vendor preset: enabled)
   Active: active (exited) since Mon 2020-01-27 12:25:55 CET; 1s ago
  Process: 5541 ExecStart=/usr/bin/init-zram-swapping (code=exited, status=0/SUCCESS)
 Main PID: 5541 (code=exited, status=0/SUCCESS)

Jan 27 12:25:55 myhost systemd[1]: Starting Initializes zram swaping...
Jan 27 12:25:55 myhost init-zram-swapping[5541]: Setting up swapspace version 1, size = 985,7 MiB (1033568256 bytes)
Jan 27 12:25:55 myhost init-zram-swapping[5541]: nessuna etichetta, UUID=4ac5c2cd-0c68-4f6d-a5c0-d8f91a509c71
Jan 27 12:25:55 myhost init-zram-swapping[5541]: Setting up swapspace version 1, size = 985,7 MiB (1033568256 bytes)
Jan 27 12:25:55 myhost init-zram-swapping[5541]: nessuna etichetta, UUID=83a4f201-d591-4222-89a6-5bc5aebedef4
Jan 27 12:25:55 myhost init-zram-swapping[5541]: Setting up swapspace version 1, size = 985,7 MiB (1033568256 bytes)
Jan 27 12:25:55 myhost init-zram-swapping[5541]: nessuna etichetta, UUID=1f6f742e-6fb8-4332-b226-bf6918f7ee28
Jan 27 12:25:55 myhost init-zram-swapping[5541]: Setting up swapspace version 1, size = 985,7 MiB (1033568256 bytes)
Jan 27 12:25:55 myhost init-zram-swapping[5541]: nessuna etichetta, UUID=a5509c55-46f5-4112-8fe1-68171f31409e
Jan 27 12:25:55 myhost systemd[1]: Started Initializes zram swaping.

I really don't understand what's wrong with systemd on my Ubuntu install, is it better I do a fresh reinstall of whole OS?

Thanks

1
Exactly same issue here, no one?Linightz
This is happening to me too! Loaded and enabled but not starting. No errors for cyclical dependencies either.PhilBot
I'm having the same issue. Service is enabled, do a daemon reload. Restart the instance, nothing. However, if I manually start the service it runs. Very stumped on this one.rhino5oh

1 Answers

0
votes

Check the full output of journalctl for a message about cycles, like:

Job <your.service> deleted to break ordering cycle starting with <something else>

I had the similar issue. It was due to ordering cycles, which was very hard to debug and fix.