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

Auto shutdown and restart bot periodically #51

Merged
merged 1 commit into from
Apr 16, 2021
Merged

Conversation

tk3369
Copy link
Member

@tk3369 tk3369 commented Apr 15, 2021

Resolves #50

Here's the current design:

  • start_bot function now takes a kwarg run_duration
  • The new auto_shutdown function spawns an async task to keep track of time
  • When current time exceeds start_time + run_duration then it just exits program
  • The run.sh script has a loop that runs forever, unless RUN_ONCE environment variable is set to yes
  • The run.sh script also accepts an environment variable RUN_DURATION_MINUTES which is set to 6 hours by default

Note 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.

@tk3369 tk3369 mentioned this pull request Apr 15, 2021
@Azzaare Azzaare merged commit 1c546d7 into main Apr 16, 2021
@Azzaare Azzaare deleted the tk/managed-restart branch April 16, 2021 08:44
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.

Improve reliability
2 participants