You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.js
+34-1Lines changed: 34 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,10 @@ class ServerlessDynamodbLocal {
88
88
convertEmptyValues: {
89
89
shortcut: "e",
90
90
usage: "Set to true if you would like the document client to convert empty values (0-length strings, binary buffers, and sets) to be converted to NULL types when persisting to DynamoDB.",
91
-
}
91
+
},
92
+
leaveOn: {
93
+
usage: 'Keep the process running until user sends kill command. This will kill the process the database is running once user sends terminate.'
94
+
}
92
95
}
93
96
},
94
97
noStart: {
@@ -254,8 +257,20 @@ class ServerlessDynamodbLocal {
254
257
}else{
255
258
this.serverlessLog("Skipping start: DynamoDB Local is not available for stage: "+this.stage);
256
259
}
260
+
261
+
returnBbPromise.resolve()
262
+
.then(()=>options.migrate&&this.migrateHandler())
263
+
.then(()=>options.seed&&this.seedHandler())
264
+
.then(()=>{
265
+
if(options.leaveOn){
266
+
returnBbPromise.resolve()
267
+
.then(()=>this._listenForTermination())
268
+
.then(()=>this.endHandler());
269
+
}
270
+
});
257
271
}
258
272
273
+
259
274
endHandler(){
260
275
if(this.shouldExecute()&&!this.options.noStart){
261
276
this.serverlessLog("DynamoDB - stopping local database");
@@ -286,6 +301,24 @@ class ServerlessDynamodbLocal {
286
301
}).filter((n)=>n);
287
302
}
288
303
304
+
_listenForTermination(){
305
+
// SIGINT will be usually sent when user presses ctrl+c
306
+
constwaitForSigInt=newPromise(resolve=>{
307
+
process.on('SIGINT',()=>resolve('SIGINT'));
308
+
});
309
+
310
+
// SIGTERM is a default termination signal in many cases,
311
+
// for example when "killing" a subprocess spawned in node
0 commit comments