GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix standalone server not catching SIGINT/SIGTERM by baltasarblanco · Pull Request #3799 · golemcloud/golem

Conversation

@baltasarblanco

@baltasarblanco baltasarblanco commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #1603

Problem

golem server run never installs a signal handler — the run path just awaits the services' JoinSet until completion. Running natively that is invisible: with no handler installed, the kernel applies SIGINT's default disposition and the process dies. But when the standalone server runs as PID 1 in a container (the Docker repro in the issue), the kernel only delivers a signal to a PID namespace's init process if init has installed a handler for it — default dispositions are never applied (pid_namespaces(7)). So SIGINT (Ctrl+C, kill -INT 1) and SIGTERM (docker stop) are silently discarded, which matches every observation in the issue thread.

Fix

Wrap the join_next() loop in ServerSubcommand::Run in a tokio::select! against a shutdown signal (SIGINT + SIGTERM via tokio::signal::unix on Unix, ctrl_c() elsewhere). On signal: log, join_set.shutdown().await, and return. Aborting the tasks drops the router task, which owns the worker executor's RunDetails; its Drop cancels the graph-wide shutdown token and stops the epoch thread — the same mechanism already documented in cli/golem/src/router.rs ("Dropping its RunDetails cancels the shutdown token that drives background services").

One file changed, no new dependencies (tokio already has the signal feature enabled workspace-wide).

Verification

Reproduced the PID 1 condition without Docker, since the bug's trigger is being the init of a PID namespace: sudo unshare --fork --pid --mount-proc ./target/debug/golem server run -vv.

Before (main):

  • Normal process: kill -INT <pid> kills it instantly (kernel default action, no shutdown of any kind).
  • As PID 1: the same kill -INT is silently ignored; the server keeps running and can only be stopped with SIGKILL.

After (this branch):

  • Both cases shut down cleanly on SIGINT and SIGTERM, logging Received shutdown signal, stopping Golem server, with exit code 0.
  • The shutdown token propagates to the background services; depending on timing you can see the scheduler log Shutdown requested, stopping scheduler background loop before the process exits.

cargo build -p golem and cargo make fix pass.

Note: on unpatched versions, docker run --init works around the issue, since tini becomes PID 1 and forwards signals.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
baltasarblanco added 2 commits August 29, 2026 17:11
@baltasarblanco
Fix standalone server not catching SIGINT/SIGTERM
f624b4a
@baltasarblanco
Fix standalone server not catching SIGINT/SIGTERM
e1611c5
@baltasarblanco
baltasarblanco requested a review from a team August 31, 2026 16:32
@netlify

netlify Bot commented Aug 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

✅ Deploy Preview for golemcloud canceled.

Name Link
🔨 Latest commit 78d4a0d
🔍 Latest deploy log https://app.netlify.com/projects/golemcloud/deploys/6abcf5908c9b480008aa9b26
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Aug 31, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

✅ All contributors have signed the CLA.
Posted by the CLA Assistant Lite bot.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown

Hi @baltasarblanco, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/golemcloud/golem/blob/main/CONTRIBUTING.md for more details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Aug 31, 2026
@baltasarblanco

baltasarblanco commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

github-actions Bot added a commit that referenced this pull request Aug 31, 2026
@github-actions
@baltasarblanco has signed the CLA in #3799
371faf1
@vigoo vigoo reopened this Sep 1, 2026
@vigoo
Merge branch 'main' into fix/standalone-server-sigint
c1c39f7
vigoo
vigoo reviewed Sep 2, 2026
View reviewed changes
Comment thread cli/golem/src/command_handler.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

baltasarblanco and others added 5 commits September 2, 2026 12:57
@baltasarblanco
Race shutdown signal with service startup
52bf3f9
@baltasarblanco
Merge remote-tracking branch 'upstream/main' into fix/standalone-serv…
6dea68d
…er-sigint
@vigoo
Merge remote-tracking branch 'origin/main' into fix-pr-3799
32ef47b
@vigoo @ampagent
Wait for standalone server cleanup on shutdown
e6356e1
Amp-Thread-ID: https://ampcode.com/threads/T-01a0f15c-90c7-7576-bf7c-09ae4b194634
Co-authored-by: Amp <[email protected]>
@vigoo
Merge branch 'main' into fix/standalone-server-sigint
78d4a0d
@vigoo
vigoo merged commit b1bce37 into golemcloud:main Sep 30, 2026
66 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 30, 2026
@baltasarblanco
baltasarblanco deleted the fix/standalone-server-sigint branch September 30, 2026 14:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@vigoo vigoo vigoo left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Golem standalone server doesn't catch SIGINT

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@baltasarblanco @vigoo
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.