-
Notifications
You must be signed in to change notification settings - Fork 39
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
Continuous saving of history #112
Comments
Yes, history is currently saved on exit. Being able to protect it from OS crashes, power failures, etc would be an improvement. |
I guess, making scli react properly to a SIGTERM would already do a lot. Not about crashed, but about beeing shutdown by the terminating desktop session. |
Might pull request this in as a feature in next few days, the code has no comments and makes it a wee bit hard for me to get a full grasp on mentally and I want to make something that works clean, might not though. |
Attempt to shutdown gracefully on receiving SIGTERM or SIGHUP from another process. This allows to properly save the conversation history. Ref. isamert#112
Prevent loosing past conversation history due to system crashes, etc. Ref. isamert#112
@NK308, thanks for the suggestion! I've added a handler for the Yes, this still does not protect the history file from system crashes or hangups. To limit the damage in those events, I've also added instructions to backup the history file on startup. Now the loss is limited to the last session, rather than the whole JSON file getting corrupted. A proper long-term solution would be to store the conversations history in a database instead of a JSON file. This would be more efficient and reliable, since the new messages could be added incrementally, rather than the whole JSON structure re-written on every exit. |
@obnoxiousish, the signals handling should be taken care of, AFAICT, but feel free to make a PR with additional changes for this or other issues. Yes, the code documentation is not extensive. The code itself is somewhat modular - you don't have to understand everything to make improvements - but having an overview of how the pieces fit together helps. Feel free to open a new discussion if you have questions. |
It seems to work now with the development branch. Messages now survive, when I log out of i3, or reboot, while scli is still open. |
I fear, I have to correct my previous statement. Writing messages to myself, between scli and android, leads to a correctly saved chat (which was my way of testing the commit), but chats with other contacts don't seem to be saved, like before. |
For the purposes of saving the conversations history, in scli there should be no difference between messages-to-self and messages to others. I have just tested sending a message to another number, and issuing a |
I checked again and the problem doesn't seem to be, with whom I'm messaging, but if I just log out of my i3 desktop session, or shutdown/reboot my machine. The exit command from i3, which logs me out of the desktop session and leads me back to sddm seems let close scli properly, while systemctl poweroff/shutdown don't. I actually expected systemctl to give the programs time for this, until it kills them forcefully. |
Normally, on shutdown the system sends a You can check which signals a process gets on system shutdown with
Apparently, a Note: the above is not about scli specifically. Scli should now handle |
I did tests on various ways to exit the desktop now, under i3 as well as KDE (both under Ubuntu 20.04).
so strace itself seems to be cut off, before logging, what happens to the process. Only exceptions are
which is still cut off before logging, which signal actually is received.
|
I've tried some of those shutdown commands on a DebianVM - all gave me the same Not sure why a processes would be interrupted more abruptly.. Maybe it's the terminal emulator that kills all its child processes? You can try closing all the terminal windows before executing the shutdown command, and executing the shutdown command from either a new terminal or through a GUI menu. Or use |
Attempt to shutdown gracefully on receiving SIGTERM or SIGHUP from another process. This allows to properly save the conversation history. Ref. isamert#112
Prevent loosing past conversation history due to system crashes, etc. Ref. isamert#112
Are there any plans to make a periodic history save? E.g. once a day or something, just so one doesn't have to manually quit and start the chat again? |
This might be a good stop-gap measure until we implement a proper database. |
Typing I have it running via a git checkout, branch |
See https://github.com/isamert/scli/blob/master/README.md#history You need to put |
bumping this issue, as it happened to me multiple times the last days i'm using a battery powered device, which can run out of power and even if scli was just idling (aka no messages) for a long time, the session history is gone it would be nice to have the history saved, either on every message (ideal) or every X minutes |
If I understand it correctly history is only saved on exit. Would it also be possible to save continuously from time to time? Since sometimes if I just shutdown my computer without explicitly closing scli it seems the history is not saved.
The text was updated successfully, but these errors were encountered: