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 {
9
9
10
10
constructor ( ) {
11
11
this . _elastalertPath = config . get ( 'elastalertPath' ) ;
12
+ this . _onExitCallbacks = [ ] ;
12
13
this . _status = Status . IDLE ;
13
14
14
15
/**
@@ -18,6 +19,10 @@ export default class ProcessController {
18
19
this . _process = null ;
19
20
}
20
21
22
+ onExit ( onExitCallback ) {
23
+ this . _onExitCallbacks . push ( onExitCallback ) ;
24
+ }
25
+
21
26
get status ( ) {
22
27
return this . _status ;
23
28
}
@@ -112,6 +117,12 @@ export default class ProcessController {
112
117
this . _status = Status . ERROR ;
113
118
}
114
119
this . _process = null ;
120
+
121
+ this . _onExitCallbacks . map ( function ( onExitCallback ) {
122
+ if ( onExitCallback !== null ) {
123
+ onExitCallback ( ) ;
124
+ }
125
+ } ) ;
115
126
} ) ;
116
127
117
128
// Set listener for ElastAlert error
Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ export default class ElastalertServer {
69
69
self . _fileSystemController = new FileSystem ( ) ;
70
70
self . _processController = new ProcessController ( ) ;
71
71
self . _processController . start ( ) ;
72
+ self . _processController . onExit ( function ( ) {
73
+ // If the elastalert process exits, we should stop the server.
74
+ process . exit ( 0 ) ;
75
+ } ) ;
72
76
73
77
self . _rulesController = new RulesController ( ) ;
74
78
self . _templatesController = new TemplatesController ( ) ;
You can’t perform that action at this time.
0 commit comments