Skip to content

fix: app now stops on Ctrl+C when running in Docker#20

Merged
fey merged 1 commit into
hexlet-components:mainfrom
8uben:fix/ctrl-c-docker-signal
Jun 1, 2026
Merged

fix: app now stops on Ctrl+C when running in Docker#20
fey merged 1 commit into
hexlet-components:mainfrom
8uben:fix/ctrl-c-docker-signal

Conversation

@8uben
Copy link
Copy Markdown
Contributor

@8uben 8uben commented May 30, 2026

Replace shell pipeline (| pino-pretty) with fastify-cli's built-in options loading (-o). The logger transport with pino-pretty (singleLine) is configured via the exported 'options' constant in server/plugin.js.

Using 'exec' makes fastify PID 1, so Docker signals (SIGINT/SIGTERM) are delivered directly to the Node.js process instead of being lost by the shell.

Closes #11

Rebuild the image before running

$ docker run -p 3000:3000 -e SERVER_MESSAGE="Hexlet Awesome Server" -e SENTRY_DSN="<your dsn>" hexletcomponents/devops-example-app
[17:16:29.427] INFO (1): incoming request {"reqId":"req-5","req":{"method":"GET","url":"/assets/css/bootstrap.min.css.map","host":"localhost:3000","remoteAddress":"172.17.0.1","remotePort":32854}}
[17:16:29.429] INFO (1): request completed {"reqId":"req-5","res":{"statusCode":200},"responseTime":1.9774219989776611}
[17:16:29.461] INFO (1): incoming request {"reqId":"req-6","req":{"method":"GET","url":"/favicon.ico","host":"localhost:3000","remoteAddress":"172.17.0.1","remotePort":32854}}
[17:16:29.461] INFO (1): Route GET:/favicon.ico not found {"reqId":"req-6"}
[17:16:29.462] INFO (1): request completed {"reqId":"req-6","res":{"statusCode":404},"responseTime":0.43787600100040436}
^CReceived signal SIGINT
[17:16:32.880] WARN (1): Closed

Replace shell pipeline (| pino-pretty) with fastify-cli's built-in
options loading (-o). The logger transport with pino-pretty (singleLine)
is configured via the exported 'options' constant in server/plugin.js.

Using 'exec' makes fastify PID 1, so Docker signals (SIGINT/SIGTERM)
are delivered directly to the Node.js process instead of being lost
by the shell.

Closes hexlet-components#11
@fey fey merged commit ac4d1bc into hexlet-components:main Jun 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Приложение не останавливается на ctrl+c при запуске в докере

2 participants