Skip setupCheckers when SHUTDOWN_MODE is on#22
Merged
Merged
Conversation
Production was unresponsive to /help even though the inbound shutdown middleware was in place: setupCheckers still spun up the price/shift updaters and the alert/shift checkers, which pegged the worker at ~100% CPU and starved the Telegraf polling loop so the farewell never made it out. Gate setupCheckers() on isShutdownMode(). When the flag is on the bot only initialises Telegraf to reply with the farewell — no cron, no price updaters, no alert/shift checkers, no payment polling. The lower-level notification gates in sendTriggeredAlert / checkTriggeredShiftsAndSendMessage stay as a defence-in-depth net for the case where the flag is toggled on a running instance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Production was unresponsive to
/helpeven with the inboundshutdownModemiddleware in place:setupCheckers()kept spinning up the price/shift updaters and alert/shift checkers, which pegged the DO App Platform worker at ~100% CPU and starved the Telegraf polling loop so the farewell never made it out.This PR gates
setupCheckers()onisShutdownMode()insrc/app.ts. WhenSHUTDOWN_MODE=true, the bot only initialises Telegraf to reply with the farewell — no cron, no price updaters, no alert/shift checkers, no payment polling.The lower-level notification gates added in #21 stay in place as defence-in-depth for the case where the flag is toggled on an already-running instance.
Production evidence
DO worker
goose(app1cc538dc-0e90-484e-8109-fb51e361b887) reportedstate: UNHEALTHY,cpu_usage_percent: 99.92. Run logs from the merged-but-still-running deployment showed continuous[CHECK ALERTS] Alert trigger check,[CANDLES UPDATER], and[PRICE UPDATER]activity, plus repeatedDuplicate alert trigger attempterrors (the lower-level gate skipped the send, so alerts stayed in the cache and re-triggered every poll cycle).Test plan
npx jest— 13 suites / 69 tests passingnpm run lintnpm run build/helpreplies with the farewell within seconds