Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nzbhydra.service #446

Merged
merged 4 commits into from
Nov 28, 2016
Merged

Update nzbhydra.service #446

merged 4 commits into from
Nov 28, 2016

Conversation

MarMed
Copy link
Contributor

@MarMed MarMed commented Nov 28, 2016

Made it that systemd always knows the PID even after restart.

You must turn on Shutdown to restart to avoid multiple instances.

Known issues:
Shutdown from the web will restart, must shutdown from systemd.

Made it that systemd always knows the PID even after restart.

You must turn on Shutdown to restart to avoid multiple instances.

Known issues:
Shutdown from the web will restart, must shutdown from systemd.
@theotherp
Copy link
Owner

Isn't there some way of telling the service manager to not restart the underlying program under certain circumstances, e.g. exit codes?

@MarMed
Copy link
Contributor Author

MarMed commented Nov 28, 2016

I was going to submit that, but I did it by changing the shutdown exit code to 6 but it's unconventional for a successful exit. I had it working perfectly with this method, the issue could be for anyone who is using their own service script it would come up as a failure.

@theotherp
Copy link
Owner

Well, I could add an option which exit code to use when shutting down...

Quick and dirty fix changing shutdown exit code to 6 and telling systemd to consider it a success
Change shutdown exit code to 6
@theotherp
Copy link
Owner

Cool.

@MarMed
Copy link
Contributor Author

MarMed commented Nov 28, 2016

If possible I think the shutdown on restart exit code should be 0

@theotherp
Copy link
Owner

It is. At least it's supposed to be.

@MarMed
Copy link
Contributor Author

MarMed commented Nov 28, 2016

Sorry, it is currently but with my code change it changes it to 6 as I assume it just calls the regular shutdown, if a new shutdown on restart with exit 0 it should all work, with the current setup shutdown t restart shuts down.

edit: newest commit does exactly this

I've made some assumptions with the code here, but it is working with this change.
@theotherp
Copy link
Owner

Then what's shutdownforrestart() for?

@MarMed
Copy link
Contributor Author

MarMed commented Nov 28, 2016

My previous comment was from uncertainty of how ShutdownForRestart works.
So with commit aa8fa23:

A normal shutdown exits with 6 and is defined in systemd as a clean shutdown and told not to restart RestartPreventExitStatus=6

A restart with ShutdownForRestart enabled exits with 0 systemd restarts the command Restart=on-success

@theotherp
Copy link
Owner

Hm, I don't want to change the default exit code to anything but 0.

I could send exit code 0 when shutting down for restart and 6 for regular shutdown but only if "shutdown to restart" is set.

That way for regular use exit code 0 is used for successful shutdown and restart is handled by hydra and all is well. When run in a service manager enable "Shutdown for restart" and 0 means restart and 6 means shut down for good.

Agreed?

@MarMed
Copy link
Contributor Author

MarMed commented Nov 28, 2016

Agreed, That is definitely ideal, I just couldn't wrap my head around it.

@theotherp theotherp merged commit aa8fa23 into theotherp:master Nov 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants