slackminion icon indicating copy to clipboard operation
slackminion copied to clipboard

Save State

Open balajijegan opened this issue 7 years ago • 3 comments

  • Currently the save state is called only on stop. If the bot terminates abnormally for whatever reason, this can cause state to be lost. Case in point when the bot has been running for several days.

https://github.com/arcticfoxnv/slackminion/blob/e22601353f82ea2395a32933f4c2355374957d0b/slackminion/bot.py#L137

  • Propose setting a timer to save state periodically. May be once a day.

Thoughts?

balajijegan avatar Sep 07 '18 16:09 balajijegan

I dont know how I would do this either, so appreciate feedback or pointers on how to do this.

balajijegan avatar Sep 07 '18 16:09 balajijegan

A periodic save would definitely be good to have. It was probably just an oversight on my part that it doesn't currently do so. Current thinking is that plugins can start timers which run in separate threads, so we could probably use that to save state. https://github.com/arcticfoxnv/slackminion/blob/e22601353f82ea2395a32933f4c2355374957d0b/slackminion/plugin/base.py#L65-L72 We could either update the core plugin, or add a new plugin (maybe in slackminion/slackminion/plugins/state/) to schedule timers for saving state. I suppose it doesn't have to be in a plugin, but I want to try and keep as much in plugins as possible, so bot functionality can be more easily customized as needed.

arcticfoxnv avatar Sep 09 '18 21:09 arcticfoxnv

The state should be saved anytime a savable plugin attribute is updated. Otherwise there is a risk of state rollback if the bot terminates unexpectedly. I've added this as a one-off to some of our internal plugins but it should really be implemented in BasePlugin I think. I'll try to work on this sometime soon.

amckenna-pinterest avatar Nov 17 '21 00:11 amckenna-pinterest