#1 - Control de Signals y Cambios en Dockerfile
This commit is contained in:
parent
e846a8293d
commit
ee371b82d0
6
Dockerfile
Normal file
6
Dockerfile
Normal file
@ -0,0 +1,6 @@
|
||||
FROM docker.io/library/node:22-alpine
|
||||
LABEL org.opencontainers.image.source https://gianet.us/codyops/nucleus
|
||||
COPY . /opt
|
||||
WORKDIR /opt
|
||||
RUN npm run build
|
||||
CMD npm run start
|
@ -4,7 +4,7 @@
|
||||
"description": "CodyOps Nucleus",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "npx tsc",
|
||||
"build": "npm i && npx tsc",
|
||||
"start": "node dist/main.js",
|
||||
"dev": "tsc-watch --noClear --onSuccess 'node ./dist/main.js'"
|
||||
},
|
||||
|
21
src/main.ts
21
src/main.ts
@ -35,6 +35,23 @@ app.post(`/${processor}`, jsonParser, async (req: Request, res: Response) => {
|
||||
res.sendStatus(201);
|
||||
})
|
||||
|
||||
app.listen(port, () => {
|
||||
const server = app.listen(port, () => {
|
||||
console.log('Serving function...');
|
||||
});
|
||||
});
|
||||
|
||||
function shutdown(signal: string) {
|
||||
console.log(`Received ${signal}. Shutting down gracefully...`);
|
||||
|
||||
server.close(() => {
|
||||
console.log('HTTP server closed.');
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
console.error('Forced shutdown due to timeout.');
|
||||
process.exit(1);
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
||||
process.on('SIGINT', () => shutdown('SIGINT')); // Handles Ctrl+C
|
||||
|
Loading…
x
Reference in New Issue
Block a user