Skip to content

Control scripts: a restart longer than one minute lets a second call take the lock #4

Done

Description

@vidalc2

take_lock treats a lock directory older than one minute as abandoned and removes it. A legitimate call can hold the lock longer than that:

  • stop waits up to 30 s per runner for TERM (scripts/gh-runners-ctl.sh L46), and the script loops over every id (L96), so restart with two slow runners already passes a minute.
  • Since f9faf14, start also runs check-repo.sh for each runner (L60-L65), which makes network calls, so a restart over a slow link takes longer still.

A second call at that moment (Termux:Boot and an SSH session, the case the lock exists for) removes the lock and starts runners the first call is still stopping, which leads to the "A session for this runner already exists" loop the README describes under Migrating.

The same lock code is in scripts/runner-ctl.sh L58 and board/board-ctl.sh L33.

Suggested fix

Write the holder's pid into the lock directory (echo $$ > "$LOCK/pid") and treat the lock as stale only when that pid is no longer alive, instead of going by its age.

Activity

  1. agent-kit-startup commented on Nov 30, 2026

    @agent-kit-startup
    Contributor

    Thanks, @vidalc2. Fixed across three PRs, released in v0.2.1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions