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

added SIGTERM signal handler for main loop #4

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Conversation

bernhofer
Copy link
Contributor

@bernhofer bernhofer commented Oct 29, 2024

I've noticed that using the shell approach in a systemd service, as discussed in this issue, results in Python subprocesses not shutting down when running systemctl restart or systemctl stop (e.g., during fan curve updates). To address this, I have implemented a signal handler to ensure a graceful shutdown (and restoration of defaults) when a SIGTERM signal is received.

To make this fix effective, the ExecStart in the service configuration also needs to be updated:
ExecStart=/bin/bash -c 'cd /path/to/nvidia_fan_control_linux && source fan/bin/activate && python nvidia_fan_control.py'

@RoversX
Copy link
Owner

RoversX commented Nov 11, 2024

Sorry for the delay; I've been busy lately. Thanks for optimizing the code and adding signal handling! I haven't personally tested it as a service, but I hope it works smoothly for those who do. I assume you've tested it as well? 👏

@RoversX RoversX merged commit d6c18c7 into RoversX:main Nov 11, 2024
@bernhofer
Copy link
Contributor Author

No problem at all! Yes, I went ahead and tested it as a service with signal handling. The fan curves can be modified and applied by restarting the service. 👍

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