Skip to content

feat(remote): start and stop environments on cron schedules - #260

Merged
outofcoffee merged 8 commits into
mainfrom
feat/scheduled-remote-start-stop
Oct 7, 2026
Merged

outofcoffee merged 8 commits into
mainfrom
feat/scheduled-remote-start-stop

Conversation

@outofcoffee

Copy link
Copy Markdown
Collaborator

Remote environments can now be started and stopped on cron schedules that the AWS control plane runs, set with spinloop remote schedule.

Closes #178

Summary

  • New spinloop remote schedule set|show|clear. set takes repeatable --start and --stop cron expressions and one --timezone, and replaces the environment's whole list. show prints the schedules and the next start and stop times.
  • A new schedule Lambda stores each environment's list in SSM and keeps EventBridge Scheduler schedules in step with it, so schedules fire with none of your machines switched on. Times follow the zone's clock across daylight saving.
  • A scheduled start runs the same wake as spinloop remote start. A scheduled stop pauses the instance, and is skipped while a Retain-Until deadline (keep) has not passed.
  • New schedule_url in the environment config and SPINLOOP_REMOTE_SCHEDULE_URL. A control plane deployed before this fails the schedule commands with a message to re-run spinloop remote bootstrap.
  • OpenSpec change scheduled-remote-start-stop (new remote-schedule capability), with docs and tests.

Implementation details

  • Scheduler rather than classic EventBridge rules, because only Scheduler takes an IANA time zone. The cost is that schedules are created at run time, so the stack adds a schedule group and a role Scheduler assumes to invoke the start and stop Lambdas.
  • Input is validated before anything is written, so a rejected request changes nothing. If Scheduler fails after the list is stored, repeating the same request converges.
  • Users write five-field cron. Scheduler wants six fields, ? in the unused day field and its own weekday numbering, so the Lambda converts, and rejects an expression that sets both day fields.
  • Scheduler schedule names are a hash of the environment name plus an index, because names are capped at 64 characters and an environment name can be that long.
  • Next-run times come from a small evaluator in remote/lambda/shared/schedules.ts, not from Scheduler. There is no remote status command, so the next runs are printed by schedule show instead of a status line (the change's spec was amended to match).
  • Existing deployments need spinloop remote bootstrap re-run to get the new Lambda, URL and role.

The OpenSpec change is not archived yet.

@outofcoffee outofcoffee added the enhancement New feature or request label Oct 5, 2026
@outofcoffee
outofcoffee force-pushed the feat/scheduled-remote-start-stop branch from b8e583a to baaf5ce Compare October 5, 2026 22:18
spinloop-agent added 7 commits October 7, 2026 11:09
A schedule Lambda keeps each environment's schedule list in SSM and mirrors
it into EventBridge Scheduler, which runs the start and stop Lambdas in each
schedule's own time zone. A scheduled stop pauses the instance and is skipped
while a retention deadline is in force.

Adds spinloop remote schedule set, show and clear.
…chedule grant

A scheduled start goes through the same lock as a client's start, so a
schedule firing beside a manual start launches one instance. The schedule
Lambda's SSM access is limited to its own parameter, which keeps the start
Lambda the only one that can delete the start lock.
@outofcoffee
outofcoffee force-pushed the feat/scheduled-remote-start-stop branch from baaf5ce to 4e8fd14 Compare October 7, 2026 10:12
@outofcoffee
outofcoffee marked this pull request as ready for review October 7, 2026 10:28
@outofcoffee
outofcoffee merged commit b28ebe2 into main Oct 7, 2026
6 checks passed
@outofcoffee
outofcoffee deleted the feat/scheduled-remote-start-stop branch October 7, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: scheduled start/stop via the control plane

1 participant