File tree Expand file tree Collapse file tree 3 files changed +41
-32
lines changed
serverless-offline-dynamodb-streams/src
serverless-offline-kinesis/src
serverless-offline-s3/src Expand file tree Collapse file tree 3 files changed +41
-32
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class ServerlessOfflineDynamodbStreams {
29
29
this . hooks = {
30
30
'offline:start:init' : this . start . bind ( this ) ,
31
31
'offline:start:ready' : this . ready . bind ( this ) ,
32
- 'offline:start' : this . _startWithExplicitEnd . bind ( this ) ,
32
+ 'offline:start' : this . _startWithReady . bind ( this ) ,
33
33
'offline:start:end' : this . end . bind ( this )
34
34
} ;
35
35
}
@@ -56,24 +56,27 @@ class ServerlessOfflineDynamodbStreams {
56
56
) ;
57
57
}
58
58
59
- async ready ( ) {
59
+ ready ( ) {
60
60
if ( process . env . NODE_ENV !== 'test' ) {
61
- await this . _listenForTermination ( ) ;
61
+ this . _listenForTermination ( ) ;
62
62
}
63
63
}
64
64
65
- async _listenForTermination ( ) {
66
- const command = await new Promise ( resolve => {
67
- process . on ( 'SIGINT' , ( ) => resolve ( 'SIGINT' ) ) . on ( 'SIGTERM' , ( ) => resolve ( 'SIGTERM' ) ) ;
68
- } ) ;
65
+ _listenForTermination ( ) {
66
+ const signals = [ 'SIGINT' , 'SIGTERM' ] ;
67
+
68
+ signals . map ( signal =>
69
+ process . on ( signal , async ( ) => {
70
+ this . serverless . cli . log ( `Got ${ signal } signal. Offline Halting...` ) ;
69
71
70
- this . serverless . cli . log ( `Got ${ command } signal. Offline Halting...` ) ;
72
+ await this . end ( ) ;
73
+ } )
74
+ ) ;
71
75
}
72
76
73
77
async _startWithExplicitEnd ( ) {
74
78
await this . start ( ) ;
75
- await this . ready ( ) ;
76
- this . end ( ) ;
79
+ this . ready ( ) ;
77
80
}
78
81
79
82
async end ( skipExit ) {
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class ServerlessOfflineKinesis {
29
29
this . hooks = {
30
30
'offline:start:init' : this . start . bind ( this ) ,
31
31
'offline:start:ready' : this . ready . bind ( this ) ,
32
- 'offline:start' : this . _startWithExplicitEnd . bind ( this ) ,
32
+ 'offline:start' : this . _startWithReady . bind ( this ) ,
33
33
'offline:start:end' : this . end . bind ( this )
34
34
} ;
35
35
}
@@ -56,24 +56,27 @@ class ServerlessOfflineKinesis {
56
56
) ;
57
57
}
58
58
59
- async ready ( ) {
59
+ ready ( ) {
60
60
if ( process . env . NODE_ENV !== 'test' ) {
61
- await this . _listenForTermination ( ) ;
61
+ this . _listenForTermination ( ) ;
62
62
}
63
63
}
64
64
65
- async _listenForTermination ( ) {
66
- const command = await new Promise ( resolve => {
67
- process . on ( 'SIGINT' , ( ) => resolve ( 'SIGINT' ) ) . on ( 'SIGTERM' , ( ) => resolve ( 'SIGTERM' ) ) ;
68
- } ) ;
65
+ _listenForTermination ( ) {
66
+ const signals = [ 'SIGINT' , 'SIGTERM' ] ;
67
+
68
+ signals . map ( signal =>
69
+ process . on ( signal , async ( ) => {
70
+ this . serverless . cli . log ( `Got ${ signal } signal. Offline Halting...` ) ;
69
71
70
- this . serverless . cli . log ( `Got ${ command } signal. Offline Halting...` ) ;
72
+ await this . end ( ) ;
73
+ } )
74
+ ) ;
71
75
}
72
76
73
- async _startWithExplicitEnd ( ) {
77
+ async _startWithReady ( ) {
74
78
await this . start ( ) ;
75
- await this . ready ( ) ;
76
- this . end ( ) ;
79
+ this . ready ( ) ;
77
80
}
78
81
79
82
async end ( skipExit ) {
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class ServerlessOfflineS3 {
30
30
this . hooks = {
31
31
'offline:start:init' : this . start . bind ( this ) ,
32
32
'offline:start:ready' : this . ready . bind ( this ) ,
33
- 'offline:start' : this . _startWithExplicitEnd . bind ( this ) ,
33
+ 'offline:start' : this . _startWithReady . bind ( this ) ,
34
34
'offline:start:end' : this . end . bind ( this )
35
35
} ;
36
36
}
@@ -57,24 +57,27 @@ class ServerlessOfflineS3 {
57
57
) ;
58
58
}
59
59
60
- async ready ( ) {
60
+ ready ( ) {
61
61
if ( process . env . NODE_ENV !== 'test' ) {
62
- await this . _listenForTermination ( ) ;
62
+ this . _listenForTermination ( ) ;
63
63
}
64
64
}
65
65
66
- async _listenForTermination ( ) {
67
- const command = await new Promise ( resolve => {
68
- process . on ( 'SIGINT' , ( ) => resolve ( 'SIGINT' ) ) . on ( 'SIGTERM' , ( ) => resolve ( 'SIGTERM' ) ) ;
69
- } ) ;
66
+ _listenForTermination ( ) {
67
+ const signals = [ 'SIGINT' , 'SIGTERM' ] ;
68
+
69
+ signals . map ( signal =>
70
+ process . on ( signal , async ( ) => {
71
+ this . serverless . cli . log ( `Got ${ signal } signal. Offline Halting...` ) ;
70
72
71
- this . serverless . cli . log ( `Got ${ command } signal. Offline Halting...` ) ;
73
+ await this . end ( ) ;
74
+ } )
75
+ ) ;
72
76
}
73
77
74
- async _startWithExplicitEnd ( ) {
78
+ async _startWithReady ( ) {
75
79
await this . start ( ) ;
76
- await this . ready ( ) ;
77
- this . end ( ) ;
80
+ this . ready ( ) ;
78
81
}
79
82
80
83
async end ( skipExit ) {
You can’t perform that action at this time.
0 commit comments