File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed
packages/serverless-offline-sqs/src Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class ServerlessOfflineSQS {
45
45
this . hooks = {
46
46
'offline:start:init' : this . start . bind ( this ) ,
47
47
'offline:start:ready' : this . ready . bind ( this ) ,
48
- 'offline:start' : this . _startWithExplicitEnd . bind ( this ) ,
48
+ 'offline:start' : this . _startWithReady . bind ( this ) ,
49
49
'offline:start:end' : this . end . bind ( this )
50
50
} ;
51
51
}
@@ -72,24 +72,27 @@ class ServerlessOfflineSQS {
72
72
) ;
73
73
}
74
74
75
- async ready ( ) {
75
+ ready ( ) {
76
76
if ( process . env . NODE_ENV !== 'test' ) {
77
- await this . _listenForTermination ( ) ;
77
+ this . _listenForTermination ( ) ;
78
78
}
79
79
}
80
80
81
- async _listenForTermination ( ) {
82
- const command = await new Promise ( resolve => {
83
- process . on ( 'SIGINT' , ( ) => resolve ( 'SIGINT' ) ) . on ( 'SIGTERM' , ( ) => resolve ( 'SIGTERM' ) ) ;
84
- } ) ;
81
+ _listenForTermination ( ) {
82
+ const signals = [ 'SIGINT' , 'SIGTERM' ] ;
83
+
84
+ signals . map ( signal =>
85
+ process . on ( signal , async ( ) => {
86
+ this . serverless . cli . log ( `Got ${ signal } signal. Offline Halting...` ) ;
85
87
86
- this . serverless . cli . log ( `Got ${ command } signal. Offline Halting...` ) ;
88
+ await this . end ( ) ;
89
+ } )
90
+ ) ;
87
91
}
88
92
89
- async _startWithExplicitEnd ( ) {
93
+ async _startWithReady ( ) {
90
94
await this . start ( ) ;
91
- await this . ready ( ) ;
92
- this . end ( ) ;
95
+ this . ready ( ) ;
93
96
}
94
97
95
98
async end ( skipExit ) {
You can’t perform that action at this time.
0 commit comments