Skip to content

Commit 2d66f3c

Browse files
committed
refactor: update Docker entrypoint and improve shutdown logging
- Changed the entrypoint in Dockerfile to use ENTRYPOINT instead of CMD for better process management. - Enhanced logging in AppModule, ProcessorsRootModule, and SchedulerRootModule to provide clearer shutdown messages.
1 parent f10bf46 commit 2d66f3c

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ COPY docker-entrypoint.sh ./
7272
RUN npm install pm2 -g \
7373
&& npm link
7474

75-
CMD [ "/bin/sh", "docker-entrypoint.sh" ]
75+
76+
ENTRYPOINT [ "/bin/sh", "docker-entrypoint.sh" ]
77+
78+
CMD [ "pm2-runtime", "start", "ecosystem.config.js", "--env", "production" ]

docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ if ! npm run migrate:seed; then
1717
exit 1
1818
fi
1919

20-
echo "Starting pm2..."
21-
pm2-runtime start ecosystem.config.js --env production
22-
2320
echo "Entrypoint script completed."
21+
exec "$@"

src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ export class AppModule implements OnApplicationShutdown {
107107
private readonly logger = new Logger(AppModule.name);
108108

109109
async onApplicationShutdown(signal?: string): Promise<void> {
110-
this.logger.log(`Application shutdown signal: ${signal}`);
110+
this.logger.log(`${signal} signal received, shutting down...`);
111111
}
112112
}

src/bin/processors/processors.root.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ export class ProcessorsRootModule implements OnApplicationShutdown {
5858
private readonly logger = new Logger(ProcessorsRootModule.name);
5959

6060
async onApplicationShutdown(signal?: string): Promise<void> {
61-
this.logger.log(`Processor shutdown signal: ${signal}`);
61+
this.logger.log(`${signal} signal received, shutting down...`);
6262
}
6363
}

src/bin/scheduler/scheduler.root.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ export class SchedulerRootModule implements OnApplicationShutdown {
6565
private readonly logger = new Logger(SchedulerRootModule.name);
6666

6767
async onApplicationShutdown(signal?: string): Promise<void> {
68-
this.logger.log(`Scheduler shutdown signal: ${signal}`);
68+
this.logger.log(`${signal} signal received, shutting down...`);
6969
}
7070
}

0 commit comments

Comments
 (0)