Jump to content

Where is emby's startup script / service?


tdiguy
Go to solution Solved by dcrdev,

Recommended Posts

tdiguy

I am running ubuntu 16.04 lts and emby 3.3.1 and i was trying to follow instructions from 

https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples

in the systemd section to make my emby server a bit more hands off, it crashes every now and again and i havent been able to figure out why so i wanted to have it automatically restart. 

 

However i dont see the emby service in the /etc/systemd/system directory. Where should i find and modify it?

 

****

Ahh ok found it further on. I guess the /system directory is supposed to be for basic system things where the multi-user thing is for other stuff. 

 

Ok so far this seems pretty nice looks like now i can kill the emby process and it just starts right back like nothing happened. Not what many might consider proper or ideal. Ideally i would hunt down whatever is causing the crash and figure out how to stop it. Which i plan to do at some point. But for right now with my work schedule / overtime this will keep the family happy.

Edited by tdiguy
Link to comment
Share on other sites

dcrdev

Usually in /usr/lib/systemd/system or /lib/systemd/system , depending on distro.

 

DONT edit those files directly, changes likely won't persist through package updates.

 

Instead copy /usr/lib/systemd/system/emby-server.service to  /etc/systemd/system/emby-server.service. Units under /etc/systemd/system with the same name as units under /usr/lib/systemd/system , will take precedence i.e. override.

 

Obviously after making any changes, you need to run:

systemctl daemon-reload
Link to comment
Share on other sites

tdiguy

 

Usually in /usr/lib/systemd/system or /lib/systemd/system , depending on distro.

 

DONT edit those files directly, changes likely won't persist through package updates.

 

Instead copy /usr/lib/systemd/system/emby-server.service to  /etc/systemd/system/emby-server.service. Units under /etc/systemd/system with the same name as units under /usr/lib/systemd/system , will take precedence i.e. override.

 

Obviously after making any changes, you need to run:

systemctl daemon-reload

I ended up finding the file in /etc/systemd/system/multi-user.target.wants and i edited it there. Should i copy that file over to /usr/libs/systemd/system?

Link to comment
Share on other sites

  • Solution
dcrdev

Uh no...

 

Let me explain:

Everything in  /etc/systemd/system/multi-user.target.wants are symlinks, these symlinks are created when you enable a service.  /etc/systemd/system/multi-user.target.wants/emby-server.service will be a symlink to /usr/lib/systemd/system/emby-server.service  .

 

If you want to make changes: copy /usr/lib/systemd/system/emby-server.service to  /etc/systemd/system/emby-server.service and edit  /etc/systemd/system/emby-server.service .

 

Systemd will handle the rest, either

1) When you reboot

20 When you run systemctl daemon-reload

 

Never mess i.e. move or rename symlinks or files generated by systemd.

  • Like 1
Link to comment
Share on other sites

tdiguy

A brief summary for anyone interested:

Copy: /usr/lib/systemd/system/emby-server.service to  /etc/systemd/system/emby-server.service   And edit  emby-server.services

The file will likely look like this:

[unit]

Description=Emby Server is a personal media server with apps on just about every device.
After=network.target
 
[service]
EnvironmentFile=/etc/emby-server.conf
WorkingDirectory=/opt/emby-server
ExecStart=/opt/emby-server/bin/emby-server
RestartForceExitStatus=3
User=emby
Restart=always
 
[install]
WantedBy=multi-user.target
heath@heath-desktop:/etc/systemd/system$ cat emby-server.service
[unit]
Description=Emby Server is a personal media server with apps on just about every device.
After=network.target
 
[service]
EnvironmentFile=/etc/emby-server.conf
WorkingDirectory=/opt/emby-server
ExecStart=/opt/emby-server/bin/emby-server
RestartForceExitStatus=3
User=emby
 
[install]
WantedBy=multi-user.target
 
to have it automatically re-launch emby if it fails add: Restart=always in the service section.
 
then either reboot or reload using systemctl daemon-reload
 
Credit to @@dcrdev and  
https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples

for assistance with this.

 
 
Edited by tdiguy
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...