File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed
Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -48,21 +48,31 @@ async function main() {
4848 process . exit ( 1 ) ;
4949 } ) ;
5050
51- const ready = await waitForMongo ( ) ;
52- if ( ready ) {
53- await initReplicaSet ( ) ;
54- } else {
55- console . error ( "MongoDB did not start in time" ) ;
56- }
57-
5851 process . on ( "SIGINT" , ( ) => {
5952 mongod . kill ( "SIGINT" ) ;
6053 } ) ;
6154 process . on ( "SIGTERM" , ( ) => {
6255 mongod . kill ( "SIGTERM" ) ;
6356 } ) ;
6457
65- await new Promise ( ( resolve ) => mongod . on ( "close" , ( code ) => resolve ( code ) ) ) ;
58+ const ready = await waitForMongo ( ) ;
59+ if ( ! ready ) {
60+ console . error ( "MongoDB did not start in time" ) ;
61+ mongod . kill ( "SIGTERM" ) ;
62+ process . exit ( 1 ) ;
63+ }
64+
65+ const initialized = await initReplicaSet ( ) ;
66+ if ( ! initialized ) {
67+ console . error ( "Replica set initialization failed" ) ;
68+ mongod . kill ( "SIGTERM" ) ;
69+ process . exit ( 1 ) ;
70+ }
71+
72+ const exitCode = await new Promise ( ( resolve ) =>
73+ mongod . on ( "close" , ( code ) => resolve ( code ) )
74+ ) ;
75+ process . exit ( exitCode || 1 ) ;
6676}
6777
6878main ( ) . catch ( ( err ) => {
You can’t perform that action at this time.
0 commit comments