@@ -8,31 +8,34 @@ import { AppContext } from "./types.js";
88import { main } from "./main.js"
99import { PrismaClient } from "@sourcebot/db" ;
1010import { env } from "./env.js" ;
11+ import { createLogger } from "@sourcebot/logger" ;
12+
13+ const logger = createLogger ( 'index' ) ;
1114
1215// Register handler for normal exit
1316process . on ( 'exit' , ( code ) => {
14- console . log ( `Process is exiting with code: ${ code } ` ) ;
17+ logger . info ( `Process is exiting with code: ${ code } ` ) ;
1518} ) ;
1619
1720// Register handlers for abnormal terminations
1821process . on ( 'SIGINT' , ( ) => {
19- console . log ( 'Process interrupted (SIGINT)' ) ;
20- process . exit ( 130 ) ;
22+ logger . info ( 'Process interrupted (SIGINT)' ) ;
23+ process . exit ( 0 ) ;
2124} ) ;
2225
2326process . on ( 'SIGTERM' , ( ) => {
24- console . log ( 'Process terminated (SIGTERM)' ) ;
25- process . exit ( 143 ) ;
27+ logger . info ( 'Process terminated (SIGTERM)' ) ;
28+ process . exit ( 0 ) ;
2629} ) ;
2730
2831// Register handlers for uncaught exceptions and unhandled rejections
2932process . on ( 'uncaughtException' , ( err ) => {
30- console . log ( `Uncaught exception: ${ err . message } ` ) ;
33+ logger . error ( `Uncaught exception: ${ err . message } ` ) ;
3134 process . exit ( 1 ) ;
3235} ) ;
3336
3437process . on ( 'unhandledRejection' , ( reason , promise ) => {
35- console . log ( `Unhandled rejection at: ${ promise } , reason: ${ reason } ` ) ;
38+ logger . error ( `Unhandled rejection at: ${ promise } , reason: ${ reason } ` ) ;
3639 process . exit ( 1 ) ;
3740} ) ;
3841
@@ -60,12 +63,12 @@ main(prisma, context)
6063 await prisma . $disconnect ( ) ;
6164 } )
6265 . catch ( async ( e ) => {
63- console . error ( e ) ;
66+ logger . error ( e ) ;
6467 Sentry . captureException ( e ) ;
6568
6669 await prisma . $disconnect ( ) ;
6770 process . exit ( 1 ) ;
6871 } )
6972 . finally ( ( ) => {
70- console . log ( "Shutting down..." ) ;
73+ logger . info ( "Shutting down..." ) ;
7174 } ) ;
0 commit comments