Skip to content

Instantly share code, notes, and snippets.

@mwergles
Last active December 15, 2017 08:49
Show Gist options
  • Save mwergles/e9fef0bb8badfe98315f8aaf59052a61 to your computer and use it in GitHub Desktop.
Save mwergles/e9fef0bb8badfe98315f8aaf59052a61 to your computer and use it in GitHub Desktop.
#!/bin/sh -x
CMD="exec java -Djava.library.path=. ${JAVA_OPTS} -jar DynamoDBLocal.jar $@"
echo "#!/bin/bash
exec java -Djava.library.path=. ${JAVA_OPTS} -jar DynamoDBLocal.jar $@" > /usr/local/bin/dynamodb
chmod +x /usr/local/bin/dynamodb
/usr/local/bin/dynamodb &
PID=$!
HAS_TABLE=$(aws dynamodb list-tables --endpoint-url http://0.0.0.0:$PORT --output json | grep myTable)
if [ -z "$HAS_TABLE" ]; then
aws dynamodb create-table --table-name myTable \
--attribute-definitions AttributeName=id,AttributeType=S \
--key-schema AttributeName=id,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--endpoint-url http://0.0.0.0:$PORT
fi
kill $PID
echo "[program:dynamodb]
command=/usr/local/bin/dynamodb
autostart=true
autorestart=true" > /etc/supervisor/conf.d/dynamo.conf
supervisord -n -c /etc/supervisor/supervisord.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment