serverless-dynamodb-local
serverless-dynamodb-local copied to clipboard
Feature: Run `sls dynamodb start` in detached mode
For CI testing, one would need to run sls dynamodb start
asynchronously, because the command blocks the current shell.
Workaround 1: sls dynamodb start &
This runs it in the background, but does not wait until the db is set up properly.
Workaround 2: sls dynamodb start & sleep 5
This works, but might introduce race conditions.
Suggestion:
How about: sls dynamodb start --detached
which runs synchronously until all work is done, exits the process (the shell command is finished), but continues serving the database in the background.
Using the serverless-offline plugin, I was able to have use serverless offline start --exec "npm run test"
in order to start dynamodb before running tests. It appears that dynamodb is not shut down at the end of the run.
This is heavily blocking proper CI/CD & DevOps usage of the whole tool tbh.
Nobody in their right mind can go into a pipeline and say: "run all this, then do your test, oh and then press ctrl+c when you're done".
It is an underlying issue with dynamodb-localhost
and dynamodb-local
which this plugin straight up uses, copies, and adds bit of functionality to.
Ideally I wish to be able to dive into my npm script, start the database detached, run my tests, kill the database.
@erauer - could you specify what you used in the "test" section of your package.json (basically the command which is being run with npm run test
https://github.com/doapp-ryanp/dynamodb-local/pull/19 I managed to find the very base NPM package of this build, and got it to run in detached mode (albeit with async wrapping).
As such, this should be possible for the serverless plugin to work in this way.
Ideally I want to run in my DevOps pipeline:
sls dynamodb start --seed=test --detached
which would just start the whole database (potentially writing the child object, or child pid) to a temp file.
And kill the whole thing with sls dynamodb stop
. Even if this requires under the hood asyncing.
I have this problem too, I have to run this command, but the dynamodb start
blocks the second command.
sls dynamodb start && jest --coverage --runInBand --forceExit --detectOpenHandles
If I run the command like this the first time will work
sls dynamodb start & sleep 3 && jest --coverage --runInBand --forceExit --detectOpenHandles
But the second time I run this command this problem will occur on serverless-dynamodb-local
Could not start server on port 8000: Address already in use
I use pgrep -f "DynamoDBLocal.jar" | xargs kill
command to kill serverless dynamodb local application after test it.