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 systemd unit and make it generic #2

Closed
wants to merge 2 commits into from
Closed

Update systemd unit and make it generic #2

wants to merge 2 commits into from

Conversation

MichaIng
Copy link

In systemd it is not necessary to fork a process into background which implies the need to use Type=forking and at best create a PID file to allow systemd tracking its state. Instead one can run any process in foreground and use default Type=simple which implies STDOUT to systemd journal.

Since this systemd unit does not use any fancy new options, it can be assumed to work on any distribution, as long as the python3 executable location is the same.

The --datadir cmd option, as used here, is obsolete since userdata/ inside the git/install root is the default, but we'll leave it present to make aware of it, since often one wants to store userdata on a different location.

In systemd it is not necessary to fork a process into background which implies the need to use Type=forking and at best create a PID file to allow systemd tracking its state. Instead one can run any process in foreground and use default Type=simple which implies STDOUT to systemd journal.

Since this systemd unit does not use any fancy new options, it can be assumed to work on any distribution, as long as the python3 executable location is the same.

The --datadir cmd option, as used here, is obsolete since userdata/ inside the git/install root is the default, but we'll leave it present to make aware of it, since often one wants to store userdata on a different location.

Signed-off-by: MichaIng <[email protected]>
@gmiranda
Copy link
Owner

Thanks, will have a look at it

@gmiranda gmiranda self-requested a review August 26, 2020 09:45
How about this? The path to HTPC-Manager is only required once
Copy link
Owner

@gmiranda gmiranda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a suggestion, I think it's better since you only have to fill the application path once, and it's a bit easier when using virtual environments.

@MichaIng
Copy link
Author

MichaIng commented Aug 26, 2020

Since user + group need to be altered as well, I personally would leave it as simple template without much magic to most importantly tell users that there is no special signal/process handling required. Since --datadir does not have any effect when anyway using <HTPC>/userdata, it is probably best to leave it as /path/to/HTPCManager_data to make it more clear that it can (and probably should) be placed at a different location instead of "binding" it to the git/install path even more with the environment variable?

Also I'm no big fan of shell wrappers around the actual process. This means there is an additional bash process running all the time and systemd is actually monitoring the bash process, not the Python process. In journal, logs will be prefixed with bash (this could be changed with SyslogItentifier=HTPC Manager Daemon) and all signals are send/received through bash relying on proper forwarding, and, even that bash of course is very robust, in theory it can fail while executing Htpc.py alone could have succeeded. At least I would use sh then, which defaults to the much more lightweight dash on Debian and Ubuntu and is assured to be present on any distro, while bash is no necessarily.
exec could probably solve it as it replaced the the parent shell with the process given as argument, but I never tested it within systemd units.

IMO, keep it as simple as possible without much magic, which assures it is portable. And users who manually install HTPC Manager with or without venv will know how to set the python and Htpc.py path.

@MichaIng
Copy link
Author

I mark this as closed here, probably needs to more thoughts about having a template or an mostly OOTB functional default. There is more important things 😄.

@MichaIng MichaIng closed this Aug 30, 2020
@MichaIng MichaIng deleted the patch-2 branch August 30, 2020 19:50
gmiranda added a commit that referenced this pull request May 12, 2021
Fix invalid argument call for ModuleNotFoundError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants