Skip to content

Commit 2dd8ae5

Browse files
authored
add fix for server on sigterm (#8)
* add fix for server on sigterm * fix ci * fix ci
1 parent 4313312 commit 2dd8ae5

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v2
1111

12+
- run: make compose-build
1213
- run: make compose-test-ci
1314
- run: make compose-lint-ci

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM node:20-slim
22

3+
ENV PATH="$PATH:node_modules/.bin"
4+
35
RUN apt-get update && apt-get install -y make
46

57
WORKDIR /app

bin/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
COMMAND="npx fastify start server/plugin.js -a 0.0.0.0 -l info --pretty-logs"
5+
COMMAND="fastify start server/plugin.js -a 0.0.0.0 -l info"
66

77
echo $COMMAND
88
exec $COMMAND

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"author": "Hexlet",
1212
"license": "ISC",
1313
"dependencies": {
14+
"@dnlup/fastify-traps": "^2.0.0",
1415
"@fastify/static": "^6.10.2",
1516
"bootstrap": "^5.3.0",
1617
"dotenv": "^16.3.1",

server/plugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Pug from 'pug';
66
import pointOfView from 'point-of-view';
77
import fastifyStatic from '@fastify/static';
88
import Rollbar from 'rollbar';
9+
import traps from '@dnlup/fastify-traps';
910

1011
import addRoutes from './routes.js';
1112

@@ -47,6 +48,10 @@ const registerPlugins = (app) => {
4748
},
4849
includeViewExtension: true,
4950
templates: path.join(__dirname, '..', 'server', 'views'),
51+
}).register(traps, {
52+
onSignal(signal) {
53+
console.debug(`Received signal ${signal}`);
54+
},
5055
});
5156
};
5257

0 commit comments

Comments
 (0)