Skip to content

Skip setupCheckers when SHUTDOWN_MODE is on#22

Merged
ashugaev merged 1 commit into
masterfrom
goose-cf08
May 25, 2026
Merged

Skip setupCheckers when SHUTDOWN_MODE is on#22
ashugaev merged 1 commit into
masterfrom
goose-cf08

Conversation

@AlekShu
Copy link
Copy Markdown
Collaborator

@AlekShu AlekShu commented May 25, 2026

Summary

Production was unresponsive to /help even with the inbound shutdownMode middleware 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() on isShutdownMode() in src/app.ts. When SHUTDOWN_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 (app 1cc538dc-0e90-484e-8109-fb51e361b887) reported state: 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 repeated Duplicate alert trigger attempt errors (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 passing
  • npm run lint
  • npm run build
  • After deploy: DO worker drops back to a normal CPU profile and /help replies with the farewell within seconds

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.
@ashugaev ashugaev merged commit c9a0e1b into master May 25, 2026
3 checks passed
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.

2 participants