File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export default class ProcessController {
99
1010 constructor ( ) {
1111 this . _elastalertPath = config . get ( 'elastalertPath' ) ;
12+ this . _onExitCallbacks = [ ] ;
1213 this . _status = Status . IDLE ;
1314
1415 /**
@@ -18,6 +19,10 @@ export default class ProcessController {
1819 this . _process = null ;
1920 }
2021
22+ onExit ( onExitCallback ) {
23+ this . _onExitCallbacks . push ( onExitCallback ) ;
24+ }
25+
2126 get status ( ) {
2227 return this . _status ;
2328 }
@@ -112,6 +117,12 @@ export default class ProcessController {
112117 this . _status = Status . ERROR ;
113118 }
114119 this . _process = null ;
120+
121+ this . _onExitCallbacks . map ( function ( onExitCallback ) {
122+ if ( onExitCallback !== null ) {
123+ onExitCallback ( ) ;
124+ }
125+ } ) ;
115126 } ) ;
116127
117128 // Set listener for ElastAlert error
Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ export default class ElastalertServer {
6969 self . _fileSystemController = new FileSystem ( ) ;
7070 self . _processController = new ProcessController ( ) ;
7171 self . _processController . start ( ) ;
72+ self . _processController . onExit ( function ( ) {
73+ // If the elastalert process exits, we should stop the server.
74+ process . exit ( 0 ) ;
75+ } ) ;
7276
7377 self . _rulesController = new RulesController ( ) ;
7478 self . _templatesController = new TemplatesController ( ) ;
You can’t perform that action at this time.
0 commit comments