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

signal handling and database shutdown #315

Merged
merged 3 commits into from
Dec 28, 2018
Merged

Conversation

norbusan
Copy link
Collaborator

This PR fixes #311 : when onedrive in monitor mode is killed via SIGINT or SIGTERM (Ctrl-C or via systemctl stop), the database connection is not properly closed, and the .waf fail remains.

While this is not by itself a problem, and would be fixed by the next normal (not monitor) run, it is still undesirable to have uncommitted transaction in the waf file, which might not be properly read by other sqlite clients.

This PR adds a signal handler that destroys the itemDb object, shuts down the Curl http module, and terminates.

With this patch and running as systemd service and stopping it, the log shows:

Dec 26 23:08:24 bulldog onedrive[15878]: OneDrive monitor interval (seconds): 45
Dec 26 23:09:09 bulldog onedrive[15878]: Syncing changes from OneDrive ...
Dec 26 23:09:28 bulldog onedrive[15878]: Got termination signal, shutting down db connection
Dec 26 23:09:28 bulldog systemd[2294]: Stopping OneDrive Free Client...
Dec 26 23:09:28 bulldog systemd[2294]: onedrive.service: Succeeded.
Dec 26 23:09:28 bulldog systemd[2294]: Stopped OneDrive Free Client.

The .waf files are properly cleaned up.

Implementation details:

@norbusan
Copy link
Collaborator Author

Rebased on master

@abraunegg abraunegg added this to the 2.2.4 milestone Dec 28, 2018
@abraunegg
Copy link
Owner

LGTM & tests OK

@norbusan norbusan merged commit fcf1ef2 into master Dec 28, 2018
@norbusan norbusan deleted the norbert/signal-handling branch December 28, 2018 02:20
@lock
Copy link

lock bot commented Jan 5, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Jan 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Properly shut down database connection on SIGTERM and SIGINT
2 participants