Fix to gracefully stop bun
This commit is contained in:
parent
543081bf34
commit
90cf36b1e8
|
@ -1,5 +1,3 @@
|
||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
mongodb:
|
mongodb:
|
||||||
image: mongo:bionic
|
image: mongo:bionic
|
||||||
|
@ -16,7 +14,8 @@ services:
|
||||||
bot-api:
|
bot-api:
|
||||||
image: oven/bun:1
|
image: oven/bun:1
|
||||||
container_name: bot-api
|
container_name: bot-api
|
||||||
command: bun run docker-dev
|
entrypoint: /bin/bash -c
|
||||||
|
command: ["bun --hot run src/index.ts"]
|
||||||
working_dir: /usr/src/app
|
working_dir: /usr/src/app
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
|
|
|
@ -21,9 +21,8 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "bun run src/index.ts",
|
"start": "bun run src/index.ts",
|
||||||
"docker-dev": "bun --hot run src/index.ts",
|
|
||||||
"dev": "docker compose down -v && docker compose up",
|
"dev": "docker compose down -v && docker compose up",
|
||||||
"test": "docker compose down -v && docker compose run bot-api bun test"
|
"test": "docker compose down -v && docker compose run bot-api 'bun test'"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
|
|
|
@ -35,9 +35,15 @@ export const startApp = async () => {
|
||||||
pass: mongo_pass,
|
pass: mongo_pass,
|
||||||
});
|
});
|
||||||
mongoose.set("runValidators", true);
|
mongoose.set("runValidators", true);
|
||||||
app.listen(port, () =>
|
const server = app.listen(port, () =>
|
||||||
logger.info(`Express server listening on port ${port}`)
|
logger.info(`Express server listening on port ${port}`)
|
||||||
);
|
);
|
||||||
|
process.on("SIGTERM", () => {
|
||||||
|
server.close(() => {
|
||||||
|
logger.info('Server closed');
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
Loading…
Reference in New Issue