Systemd service not automatically starting at boot (since v9.7?)

Hello friends.

I created an additional systemd service under

/etc/systemd/system/PlexTraktSync.service

[Unit]
Description=PlexTraktSync watch daemon
After=network-online.target

[Service]
ExecStart=/root/.local/pipx/venvs/plextraktsync/bin/plextraktsync watch
Restart=on-failure
RestartSec=10
User=root
Group=root

[Install]
WantedBy=multi-user.target

and then added it in the dietpi-launcher under “Services” via “add”, so DietPi could control it during updates etc.

State
Mode
Include/Exclude
all work like a charm. but after every reboot/boot up the State jumps back to “inactive”
and I need to manually set it back to active again.

Tl;dr:
State switches from “active” to “inactive” after reboot/bootup

this systemd worked before 9.7 perfectly. it seems 9.7 update did something?

any ideas?

Can you have a look into the logs of the service, maybe we find some hints there what is going on.

you mean the logs of the systemd service? where do I find these?

here the status page:

once I manually trigger the state to active the program does what it should do.

journalctl -u PlexTraktSync.service

Can you also check

systemctl is-enabled PlexTraktSync.service

You can also try to set Restart=always in your service file.

again this morning, after boot-up, the service was back on “inactive” in the dietpi-launcher - “Services” overview.

journalctl -u PlexTraktSync.service

output:

root@DietPi:~# journalctl -u PlexTraktSync.service
-- Journal begins at Sun 2024-09-15 08:35:38 CEST, ends at Sun 2024-09-15 08:43:56 CEST. --
Sep 15 08:35:58 DietPi systemd[1]: Started PlexTraktSync watch daemon.
Sep 15 08:36:00 DietPi plextraktsync[1790]: INFO     Connecting with url:
Sep 15 08:36:00 DietPi plextraktsync[1790]:          https://192-168-8-152.96154ff6a9c2479c94d88b4063268406.plex.direct:3240
Sep 15 08:36:00 DietPi plextraktsync[1790]:          0, timeout 30 seconds
Sep 15 08:36:01 DietPi plextraktsync[1790]: ERROR    HTTPSConnectionPool(host='192-168-8-152.96154ff6a9c2479c94d88b406326840
Sep 15 08:36:01 DietPi plextraktsync[1790]:          6.plex.direct', port=32400): Max retries exceeded with url: / (Caused
Sep 15 08:36:01 DietPi plextraktsync[1790]:          by NewConnectionError('<urllib3.connection.HTTPSConnection object at
Sep 15 08:36:01 DietPi plextraktsync[1790]:          0x7fb230d64310>: Failed to establish a new connection: [Errno 111]
Sep 15 08:36:01 DietPi plextraktsync[1790]:          Connection refused'))
Sep 15 08:36:01 DietPi plextraktsync[1790]: WARNING  Adding rewritten http url to connect with:
Sep 15 08:36:01 DietPi plextraktsync[1790]:          http://192-168-8-152.96154ff6a9c2479c94d88b4063268406.plex.direct:32400
Sep 15 08:36:01 DietPi plextraktsync[1790]: INFO     Connecting with url: http://192.168.8.152:32400, timeout 30 seconds
Sep 15 08:36:01 DietPi plextraktsync[1790]: ERROR    HTTPConnectionPool(host='192.168.8.152', port=32400): Max retries
Sep 15 08:36:01 DietPi plextraktsync[1790]:          exceeded with url: / (Caused by
Sep 15 08:36:01 DietPi plextraktsync[1790]:          NewConnectionError('<urllib3.connection.HTTPConnection object at
Sep 15 08:36:01 DietPi plextraktsync[1790]:          0x7fb230d64670>: Failed to establish a new connection: [Errno 111]
Sep 15 08:36:01 DietPi plextraktsync[1790]:          Connection refused'))
Sep 15 08:36:01 DietPi plextraktsync[1790]: INFO     Connecting with url:
Sep 15 08:36:01 DietPi plextraktsync[1790]:          https://172-104-139-30.96154ff6a9c2479c94d88b4063268406.plex.direct:844
Sep 15 08:36:01 DietPi plextraktsync[1790]:          3, timeout 30 seconds
Sep 15 08:36:01 DietPi plextraktsync[1790]: ERROR    HTTPSConnectionPool(host='172-104-139-30.96154ff6a9c2479c94d88b40632684
Sep 15 08:36:01 DietPi plextraktsync[1790]:          06.plex.direct', port=8443): Max retries exceeded with url: / (Caused
Sep 15 08:36:01 DietPi plextraktsync[1790]:          by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol
Sep 15 08:36:01 DietPi plextraktsync[1790]:          (_ssl.c:1123)')))
Sep 15 08:36:01 DietPi plextraktsync[1790]: ERROR    HTTPSConnectionPool(host='172-104-139-30.96154ff6a9c2479c94d88b40632684
Sep 15 08:36:01 DietPi plextraktsync[1790]:          06.plex.direct', port=8443): Max retries exceeded with url: / (Caused
Sep 15 08:36:01 DietPi plextraktsync[1790]:          by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol
Sep 15 08:36:01 DietPi plextraktsync[1790]:          (_ssl.c:1123)')))
Sep 15 08:36:01 DietPi plextraktsync[1790]: INFO     Connecting with url: http://172.104.139.30:8443, timeout 30 seconds
Sep 15 08:36:01 DietPi plextraktsync[1790]: ERROR    ('Connection aborted.', RemoteDisconnected('Remote end closed
Sep 15 08:36:01 DietPi plextraktsync[1790]:          connection without response'))
Sep 15 08:36:01 DietPi plextraktsync[1790]: INFO     Connecting with url: http://localhost:32400, timeout 30 seconds
Sep 15 08:36:01 DietPi plextraktsync[1790]: ERROR    HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded
Sep 15 08:36:01 DietPi plextraktsync[1790]:          with url: / (Caused by
Sep 15 08:36:01 DietPi plextraktsync[1790]:          NewConnectionError('<urllib3.connection.HTTPConnection object at
Sep 15 08:36:01 DietPi plextraktsync[1790]:          0x7fb230c945b0>: Failed to establish a new connection: [Errno 111]
Sep 15 08:36:01 DietPi plextraktsync[1790]:          Connection refused'))
Sep 15 08:36:01 DietPi plextraktsync[1790]: INFO     Connecting with url:
Sep 15 08:36:01 DietPi plextraktsync[1790]:          http://192-168-8-152.96154ff6a9c2479c94d88b4063268406.plex.direct:32400
Sep 15 08:36:01 DietPi plextraktsync[1790]:          , timeout 30 seconds
Sep 15 08:36:01 DietPi plextraktsync[1790]: ERROR    HTTPConnectionPool(host='192-168-8-152.96154ff6a9c2479c94d88b4063268406
Sep 15 08:36:01 DietPi plextraktsync[1790]:          .plex.direct', port=32400): Max retries exceeded with url: / (Caused by
Sep 15 08:36:01 DietPi plextraktsync[1790]:          NewConnectionError('<urllib3.connection.HTTPConnection object at
Sep 15 08:36:01 DietPi plextraktsync[1790]:          0x7fb230c94d90>: Failed to establish a new connection: [Errno 111]
Sep 15 08:36:01 DietPi plextraktsync[1790]:          Connection refused'))
Sep 15 08:36:01 DietPi plextraktsync[1790]: CRITICAL Error running watch command: No more methods to connect. Giving up
Sep 15 08:36:01 DietPi systemd[1]: PlexTraktSync.service: Succeeded.
Sep 15 08:36:01 DietPi systemd[1]: PlexTraktSync.service: Consumed 1.347s CPU time

weirdly I get here error messages directly after a fresh boot up.

But when triggering to “active” via the dietpí-launcher GUI it works first

and then repeat

journalctl -u PlexTraktSync.service

I get output:

Sep 15 08:59:13 DietPi systemd[1]: Started PlexTraktSync watch daemon.
Sep 15 08:59:14 DietPi plextraktsync[4760]: INFO     Connecting with url:
Sep 15 08:59:14 DietPi plextraktsync[4760]:          https://192-168-8-152.96154ff6a9c2479c94d88b4063268406.plex.direct:3240
Sep 15 08:59:14 DietPi plextraktsync[4760]:          0, timeout 30 seconds
Sep 15 08:59:14 DietPi plextraktsync[4760]: INFO     Listening for events!
Sep 15 08:59:14 DietPi plextraktsync[4760]: INFO     Server connected: DietPi (1.41.0.8992-8463ad060)
Sep 15 08:59:14 DietPi plextraktsync[4760]: INFO     Starting AlertListener:
Sep 15 08:59:14 DietPi plextraktsync[4760]:          wss://192-168-8-152.96154ff6a9c2479c94d88b4063268406.plex.direct:32400/
Sep 15 08:59:14 DietPi plextraktsync[4760]:          :/websockets/notifications?X-Plex-Token=<hidden>
Sep 15 08:59:14 DietPi plextraktsync[4760]: INFO     Websocket connected

systemctl is-enabled PlexTraktSync.service

output:

root@DietPi:~# systemctl is-enabled PlexTraktSync.service
enabled

I tried to set Restart=always in my service file. and then I typed

sudo systemctl daemon-reload
sudo systemctl start PlexTraktSync.service
sudo systemctl enable PlexTraktSync.service

after that It seems that the service stays active after reboot. im not sure if it was because of the Restart=alwayschange or rather because of

sudo systemctl daemon-reload
sudo systemctl start PlexTraktSync.service
sudo systemctl enable PlexTraktSync.service

Probably the service is starting to early and would need to be delayed on boot.

It seems to work now, but just in case. How would I delay PlexTraktSync.service?

Yes, I think it tries to connect to your plex server to early.

You could modify your service file so it’s waiting for the plex server before it tries connect to it.

 [Unit]
   Description=PlexTraktSync watch daemon
   After=network.target plexmediaserver.service
   Requires=plexmediaserver.service

thanks