mdhiggins/PlexAutoSkip

Run as a service?

DevMan01 opened this issue · 3 comments

Hey there, looking for the best recommendations / instructions for installing this program as a service at boot up?

Build:

OS:

Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy

PMS:

Plex Server Version: 1.31.1.6716

Python:

Version: 3.10.6

https://askubuntu.com/questions/905749/running-python-script-as-a-service-and-start-on-system-start-up

I use system.d inside the docker container with combination of s6 to run the script as service, I'd probably recommend creating a system.d service in a similar fashion. The s6 part isn't required but is just how the parent linuxserver container is setup but it should translate to Ubuntu fine

Steps to solve for the next chap:

  1. Go to /etc/systemd/system/
  2. Create a new service: sudo vim PlexAutoSkip.service
  3. Paste this template and modify accordingly:
# Plex Auto Skip Service
[Unit]
Description=Plex Autoskip

[Service]
#User=YOUR_USER
#Group=YOUR_USER_GROUP
Type=simple
Environment=LC_ALL=C.UTF-8
Environment=LANG=C.UTF-8
WorkingDirectory=/PATH/TO/MAIN.PY
ExecStart=/usr/bin/python3 /PATH/TO/MAIN/main.py
Restart=always
RestartSec=10

[Install]
WantedBy=default.target
  1. Load the new service: sudo systemctl --system daemon-reload
  2. Enable for boot up: sudo systemctl enable PlexAutoSkip.service
  3. Start the service: sudo systemctl start PlexAutoSkip.service
  4. To debug / look under the hood: sudo journalctl -f -u PlexAutoSkip.service

Nice write up, I copied this over to the wiki for future users, thanks for sharing

https://github.com/mdhiggins/PlexAutoSkip/wiki/Run-as-Service-Linux