Jump to content

point of recommendations for Windows Service


Recommended Posts

pwhodges
Posted
7 hours ago, alphaz18 said:

That behaviour would be pretty specific due to the use of nssm.

Why do you say that?  You've just been told that Emby itself doesn't respond properly to service shutdown - nssm is not the point here.

Mind you, I've never had a problem result from stopping the Emby service - but I do take care not to do it while Emby is busy (and after all, why would I do it then?).

Paul

Posted
3 hours ago, pwhodges said:

Why do you say that?  You've just been told that Emby itself doesn't respond properly to service shutdown - nssm is not the point here.

Mind you, I've never had a problem result from stopping the Emby service - but I do take care not to do it while Emby is busy (and after all, why would I do it then?).

Paul

well i say that because it's not that emby that doesn't respond well to service shutdown, because emby isn't a service. its just a regular process, nssm just helps to hide that fact. It's more that emby doesn't respond well to abrupt process killing. (assuming its busy) , and if emby were natively a windows service, shutting down the service would be very graceful, where as shutting it down as an nssm service could potentially be a harder process kill.

To be fair, nssm has shutdown options that let you control the shutdown behavior which is actually pretty nice of them, eg, send ctrl-c vs wm_exit or .. probably by default abrupt killing which is terminate. (terminate i believe would be equivalent to opening task manager and clicking on the task and clicking end task. that should be avoided)

Emby should be able to handle normal process shutdown, which nssm could try to emulate with those options, should be no different than having it run manually and right clicking the green status bar icon and clicking quit.

now if people are telling me that in a manually open emby with the status icon in the corner if you right click that and click quit is bad for emby. Then i would have some serious concerns because no application should behave like that, that would be a pretty big bug/defect in my view. but now i'm getting into the weeds of software development so.. i think i'll just stop there.

Also i've never had a problem from shutting down emby through any means including nssm service or manual shutdown or process killing, but that's not to say it couldn't happen. so its more of a hypothetical situation for me. but if its indeed happening that emby is being terminated hard when using nssm, then may i suggest changing the recommendations to say when using nssm to change the shutdown options and make sure terminate isn't selected.

Happy2Play
Posted

Personally, I see all of this as an optional argument as you can configure it how you like.

But if I click Shutdown in Emby and it Restarts that is not expected behavior and is why the KB recommend to setup to SHUTDOWN from my understanding.

 

Posted
6 minutes ago, Happy2Play said:

Personally, I see all of this as an optional argument as you can configure it how you like.

But if I click Shutdown in Emby and it Restarts that is not expected behavior and is why the KB recommend to setup to SHUTDOWN from my understanding.

 

it is an optional argument, you're right.

also touche, hah :D, true that clicking shutdown and it restarting is not expected behavior, I can't argue that.

on the other hand i see emby as a 24/7 kind of service that should never really be turned off :D 

 

 

rbjtech
Posted (edited)

Just seen this thread was continuing .. haha

So you can get nssm to run a graceful emby shutdown on a failure - by just sending it the API shutdown request -

curl -X POST "http://YOUR_EMBY_SERVER:8096/emby/System/Shutdown?api_key=YOUR_EMBY_API_KEY" -H "accept: */*"

This works great - you can see the graceful closedown (in the previous log) and restart (in the new log) - it restarts as the service is not 'stopped'.

I tried running the nssm stop "Emby Service" but it needs Admin to do that - there is probably a way to run a script that does do the service stop - but I'm not fussed.

It's a shame Emby does not play better with the nssm options in the UI, but tbh, I've never had an issue just stopping the service when I need to.

 

image.png.88e53c37ae525ed4ab0777ed254c7c2b.png

Edited by rbjtech
Posted
3 hours ago, rbjtech said:

Just seen this thread was continuing .. haha

So you can get nssm to run a graceful emby shutdown on a failure - by just sending it the API shutdown request -

curl -X POST "http://YOUR_EMBY_SERVER:8096/emby/System/Shutdown?api_key=YOUR_EMBY_API_KEY" -H "accept: */*"

This works great - you can see the graceful closedown (in the previous log) and restart (in the new log) - it restarts as the service is not 'stopped'.

I tried running the nssm stop "Emby Service" but it needs Admin to do that - there is probably a way to run a script that does do the service stop - but I'm not fussed.

It's a shame Emby does not play better with the nssm options in the UI, but tbh, I've never had an issue just stopping the service when I need to.

 

image.png.88e53c37ae525ed4ab0777ed254c7c2b.png

That's pretty neat/smart,

Curious question, why would we want to shutdown gracefully if it was a failure? wouldn't failure mean that the emby crashed and is already "shut down" and we want it to auto restart?

I think people wanted right click the service and stop action essentially do that that graceful shutdown, because they're concerned the service shutdown is "hard" . Though theoretical because like you I've never had any issues stopping the service either.

rbjtech
Posted (edited)
32 minutes ago, alphaz18 said:

That's pretty neat/smart,

Curious question, why would we want to shutdown gracefully if it was a failure? wouldn't failure mean that the emby crashed and is already "shut down" and we want it to auto restart?

I think people wanted right click the service and stop action essentially do that that graceful shutdown, because they're concerned the service shutdown is "hard" . Though theoretical because like you I've never had any issues stopping the service either.

Agreed - this is what I was trying to do - as you say, if emby has already crashed, then it's unlikely to accept an API request anyway.

The above API call simply 'restarts' emby gracefully using the emby UI 'shutdown' command - using just a 'restart' in the service is a hard stop/restart.

If you need to shut it down fully, then you need to stop the service - emby doesn't play nice here as you can't use the API shutdown command when it's running as a service - it just restarts it as the service does this (which is good).

Edited by rbjtech

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