@@ -36,18 +36,30 @@ class Executor {
3636 }
3737
3838 async #killProcess( process : ChildProcess ) : Promise < boolean > {
39- let killed = false ;
39+ // If the process has already been killed, return true
40+ if ( process . kill ( 0 ) === false ) {
41+ this . logger . warn ( 'Called #killProcess to kill mysqld but it has already been killed.' )
42+ return true
43+ }
44+
4045 if ( os . platform ( ) === 'win32' ) {
4146 const { error, stderr} = await this . #executeFile( 'taskkill' , [ '/pid' , String ( process . pid ) , '/t' , '/f' ] )
42- if ( ! error && ! stderr ) {
43- killed = true ;
44- } else {
45- this . logger . error ( error || stderr )
47+ const message = error || stderr
48+
49+ if ( ! message ) {
50+ return true
51+ }
52+
53+ if ( message . toString ( ) . includes ( 'There is no running instance of the task' ) ) {
54+ this . logger . warn ( 'Called #killProcess and tried to kill mysqld process but taskkill could not because it is not running. Error received:' , message )
55+ return true
4656 }
47- } else {
48- killed = process . kill ( )
57+
58+ this . logger . error ( message , '| Error toString:' , message . toString ( ) )
59+ return false
4960 }
50- return killed ;
61+
62+ return process . kill ( 'SIGKILL' )
5163 }
5264
5365 //Returns a path to the binary if it should be deleted
@@ -134,8 +146,9 @@ class Executor {
134146 fs . unwatchFile ( errorLogFile )
135147
136148 if ( signal ) {
137- this . logger . log ( 'Exiting because of aborted signal.' )
138- return
149+ this . logger . log ( 'Exiting because the process received a signal:' , signal )
150+ } else {
151+ this . logger . log ( 'Exiting with code:' , code )
139152 }
140153
141154 let errorLog : string ;
@@ -169,7 +182,9 @@ class Executor {
169182
170183 try {
171184 if ( getInternalEnvVariable ( 'deleteDBAfterStopped' ) === 'true' ) {
185+ this . logger . log ( 'Deleting database path as deleteDBAfterStopped is true...' )
172186 await fsPromises . rm ( dbPath , { recursive : true , force : true , maxRetries : 50 , retryDelay : 100 } )
187+ this . logger . log ( 'Database deletion was successful.' )
173188 }
174189 } catch ( e ) {
175190 this . logger . error ( 'An error occurred while deleting database directory at path:' , dbPath , '| The error was:' , e )
@@ -527,7 +542,7 @@ class Executor {
527542
528543 let retries = 0 ;
529544
530- this . databasePath = normalizePath ( `${ getInternalEnvVariable ( 'databaseDirectoryPath' ) } /${ randomUUID ( ) . replaceAll ( "-" , '' ) } ` )
545+ this . databasePath = normalizePath ( `${ os . tmpdir ( ) } /mysqlmsn/dbs /${ randomUUID ( ) . replaceAll ( "-" , '' ) } ` )
531546
532547 const datadir = normalizePath ( `${ this . databasePath } /data` )
533548
0 commit comments