Auto shutdown and restart bot periodically #51
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #50
Here's the current design:
start_bot
function now takes a kwargrun_duration
auto_shutdown
function spawns an async task to keep track of timestart_time
+run_duration
then it just exits programRUN_ONCE
environment variable is set toyes
RUN_DURATION_MINUTES
which is set to 6 hours by defaultNote that this is a simple design and not super-robust. For example, if there's a transaction happening (e.g. writing to a JSON file for some command) and the program exits abruptly then we may have a corrupted file. Given the current traffic, I don't think this is a big issue at the moment. We can fix that later if the bot is used more heavily.