This repository was archived by the owner on Nov 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-11
lines changed
Expand file tree Collapse file tree 1 file changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -122,17 +122,27 @@ logger.info($t("app.exitTip"));
122122logger . info ( "----------------------------" ) ;
123123console . log ( "" ) ;
124124
125+ async function processExit ( ) {
126+ try {
127+ console . log ( "" ) ;
128+ logger . warn ( "Program received EXIT command." ) ;
129+ await InstanceSubsystem . exit ( ) ;
130+ logger . info ( "Exit." ) ;
131+ } catch ( err ) {
132+ logger . error ( "ERROR:" , err ) ;
133+ } finally {
134+ process . exit ( 0 ) ;
135+ }
136+ }
137+
125138[ "SIGTERM" , "SIGINT" , "SIGQUIT" ] . forEach ( function ( sig ) {
126- process . on ( sig , async function ( ) {
127- try {
128- console . log ( "\n\n\n\n" ) ;
129- logger . warn ( `${ sig } close process signal detected.` ) ;
130- await InstanceSubsystem . exit ( ) ;
131- logger . info ( "Exit..." ) ;
132- } catch ( err ) {
133- logger . error ( "ERROR:" , err ) ;
134- } finally {
135- process . exit ( 0 ) ;
136- }
139+ process . on ( sig , ( ) => {
140+ logger . warn ( `${ sig } close process signal detected.` ) ;
141+ processExit ( ) ;
137142 } ) ;
138143} ) ;
144+
145+ process . stdin . on ( "data" , ( v ) => {
146+ const command = v . toString ( ) . replace ( "\n" , "" ) . replace ( "\r" , "" ) . trim ( ) . toLowerCase ( ) ;
147+ if ( command === "exit" ) processExit ( ) ;
148+ } ) ;
You can’t perform that action at this time.
0 commit comments