Skip to content

fix(core): gracefully stop FXServer child on shutdown signals#21

Merged
Maximus7474 merged 2 commits into
mainfrom
fix/docker
Jun 29, 2026
Merged

fix(core): gracefully stop FXServer child on shutdown signals#21
Maximus7474 merged 2 commits into
mainfrom
fix/docker

Conversation

@FjamZoo

@FjamZoo FjamZoo commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Description

Previously the core only spawned and managed the FXServer child but never handled its own termination. On SIGTERM (docker stop, systemd, etc) or SIGINT (Ctrl+C), the panel process was killed immediately and the spawned FXServer was left to be torn down abruptly rather than stopped cleanly.

This adds SIGTERM/SIGINT handlers in apps/core/src/index.ts that:

  • call ProcessManager.stop() to stop the running FXServer child,
  • close the Fastify server,
  • then process.exit(0),
  • with a shuttingDown guard so a repeated/duplicate signal is a no-op.

ProcessManager.onExit already treats exit code 143 as a clean stop, so no spurious "crashed" state is reported.


Tests

  • Tested in development mode
  • Passes typecheck
  • Builds & runs on Windows
  • Builds & runs on Linux

Additional Notes

Verified by building the Linux target and running the production binary in a container, with the server in the running state:

  • SIGTERM (docker stop): child stopped gracefully (pm.stop() ran), panel exited with code 0 in rougly 2-3 seconds.
  • SIGINT (docker kill -s SIGINT): same clean shutdown, exit code 0.
  • Restart: server starts again correctly after the process comes back up.

@Maximus7474 Maximus7474 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to hang on windows (prod build) on the fastify.close() call.
It's been a couple minutes and only process manager has been stopped.

Image

Testing code:

	try {
		await pm.stop();
		console.log('stopped process manager')
		await fastify.close();
		console.log('closed fastify server')
	} catch (err) {

@Maximus7474

Copy link
Copy Markdown
Collaborator

As @andreutu says: LGTM

@Maximus7474 Maximus7474 merged commit 33c8ec5 into main Jun 29, 2026
5 checks passed
@FjamZoo FjamZoo deleted the fix/docker branch June 29, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants