Repository navigation
Shut down on SIGTERM - #590
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The WebUI shutdown path has a startup race that can bypass Shutdown.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds graceful SIGTERM and interrupt handling so WebUI and NFConfig shut down cleanly.
Changes:
- Cancels both services on termination signals and waits for WebUI shutdown.
- Gracefully shuts down the WebUI HTTP server.
- Adds SIGTERM lifecycle coverage.
| File | Description |
|---|---|
server.go |
Coordinates signal cancellation and service shutdown. |
server_test.go |
Tests SIGTERM handling. |
backend/webui_service/webui_init.go |
Adds WebUI server shutdown logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
martin-mat
force-pushed
the
sigterm-shutdown
branch
from
October 1, 2026 22:41
3fc9f4b to
cfce6d9
Compare
Contributor
|
@martin-mat, please see this comment: omec-project/simapp#300 (comment) |
Nothing connected SIGTERM to the context that stops the servers, so the NFConfig server's graceful shutdown never ran: run as PID 1, the process was ended by the signal at once (and under a shell it was killed after the grace period). The context now comes from signal.NotifyContext, so SIGTERM and Ctrl-C stop both servers. The WebUI server is shut down as well, with the same 5 s timeout as the NFConfig server; http.ErrServerClosed from its ListenAndServe is no longer fatal, and runWebUIAndNFConfig waits for the WebUI to stop before returning, so the process exits 0. The WebUI waits for its server's configuration to end before shutting it down, so a signal during configuration cannot leave a server listening. Fixes omec-project#589 Signed-off-by: Martin Matyas <martin.matyas@tieto.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
martin-mat
force-pushed
the
sigterm-shutdown
branch
from
October 2, 2026 07:22
cfce6d9 to
b906440
Compare
gab-arrobo
enabled auto-merge (squash)
October 2, 2026 13:27
gab-arrobo
approved these changes
Oct 2, 2026
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.


Fixes #589.
runWebUIAndNFConfigcreated its context withcontext.WithCancel(context.Background()), and nothing cancelled it on a signal. So the NFConfig server's graceful shutdown (srv.Shutdownwith a 5 s timeout) never ran on SIGTERM: run as PID 1 the process was ended by the signal at once, and under a shell it was killed after the grace period.server.go: the context comes fromsignal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM). When NFConfig returns, for whatever reason, the WebUI is stopped too, and the function waits for it before returning, so the process exits 0.backend/webui_service/webui_init.go: the WebUI server is shut down on cancellation, with the same 5 s timeout as the NFConfig server.http.ErrServerClosedfrom itsListenAndServeis no longer passed toFatalln, which would otherwise end the shutdown with exit 1.server_test.go: a test sends the process SIGTERM and checks that both parts stop andrunWebUIAndNFConfigreturnsnil.Checked with
go test ./...(the new test three times in a row) and golangci-lint with the repository's configuration. On kind, with the image built from this branch running in the SD-Core chart as PID 1 (exec, as omec-project/sdcore-helm-charts#192 does for other functions): simapp's provisioning against it succeeds, and on a scale-down the pod exits with code 0 after 0.9 s, loggingNFConfig context cancelled, shutting down server.,WebUI shutting down due to context cancelandWebUI and NFConfig stopped. Before, it exited with 143 at once and logged nothing.The metrics server on :8080 still uses
http.ListenAndServewithout a handle and is simply ended with the process.🤖 Generated with Claude Code