Jump to content

Safely restart Emby from command line


Recommended Posts

SteveFintel
Posted

I have Emby running in a TrueNAS 13.1 jail. I need to periodically reboot emby-server for it to pick up an updated SSL certificate. I have been using the command line:

service emby-server restart

but I'm afraid that doesn't safely shut down and restart the process. Is there a safer way to accomplish this?

Posted

Hi, we don’t have a way from the command line at this time. I would suggest using the button in the web interface to shutdown. If you want to be able to script it then I would suggest using the Emby server api. Please let us know if this helps. Thanks.

SteveFintel
Posted

It does, a little. That leads to more programming that I think I can do - I first have to authenticate a user and then send the command. Is what I'm doing now (service emby-server restart) dangerous?

Posted

I’d probably suggest regular backups of the server data folder so that if you do run into a corrupted database you can easily restore from that.

SteveFintel
Posted

I've already been doing the daily full backups. But perhaps I'm doing this wrong. Here's what I mean: the certificate that I use to authenticate Emby over https is a Let's Encrypt certificate that is updated randomly. Every night, I run a script that builds a new .pfx file and deposit that file in /var/db/emby-server/config. The only way I know to force emby-server to 'ingest' that certificate is by rebooting it. Is there another method that would be safer?

Posted

Currently the pfx is loaded on server startup, so yes that means you have to restart. We should look at adding another way to refresh it though.

SteveFintel
Posted

OK. Reboot it is (for now).

  • Thanks 1
SteveFintel
Posted

I just realized I can authenticate from a script with an API key. Problem solved.

  • Thanks 1
  • 1 month later...
FrogMaster
Posted (edited)

Personally, I regularly use the following:

service emby-server stop 

Then I tend to do updates, ETC, and I will restart the service with

service emby-server start

I've never encountered any form of database, or data corruption while performing these actions and I've managed my server like this for years. I am doubtful you would encounter any issues by using what you've mentioned:

service emby-server restart

 

Edited by FrogMaster
SteveFintel
Posted

Thanks for this. I was doing the same thing for a while but was worried because using the shutdown link within the UI is not nearly as quick as using the command line 'service stop...' I was always wondering if it was safely shutting down processes before actually stopping. So I feel better running: 

curl -X POST http://[emby_IP_address]:8096/emby/System/Restart\?api_key=[API Key]

I believe that runs the same command that gets triggered by the UI and it just feels 'safer' to me.

  • Like 1
Posted

The command I run is this:

iocage exec emby /usr/local/bin/curl -X POST "http://[emby_server_ip]:8096/emby/System/Restart?api_key=[API_key]" -d ""
  

The "iocage exec emby" part is because I run a script in TrueNAS to update the SSL certs on several jails plus the system itself, so that commands TrueNAS to run the command inside the jail.

It's worked for 1+ years without a hitch.   Hope this helps.

  • Like 1
  • Agree 1
SteveFintel
Posted

Updating the cert in a TrueNas jail is exactly the reason I'm rebooting Emby server. It's good to know we landed on the same solution.

  • Thanks 1

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...