How to find out if local dynamodb is working?

I want to write a script that will check if a local instance of dynamodb is working, if there is one, do nothing. If not, start with:

java -Djava.library.path=. -jar DynamoDBLocal.jar

A solution that works in node.js would be better. I am using the AWS SDK for node.

+4
source share
3 answers

Since DynamoDB Local starts listening on the local port, you can check and see if there is a daemon that listens on this port using nc as follows:

 nc -z localhost 8000

It returns 0 / success if it is listening, or 1 if it is not listening.

+1
source

The following shell script checks to see if DynamoDB Local is working, and if not, it starts it.

#!/bin/sh

check_process() {
  echo "$ts: checking $1"
  [ "$1" = "" ]  && return 0
  [ `pgrep -f $1` ] && return 1 || return 0
}

echo "Checking if DynamoDB is already running..." check_process "dynamodb"
[ $? -eq 0 ] && echo "DynamoDB is not running, starting..." && `java -Djava.library.path=. -jar DynamoDBLocal.jar` &
0

DynamoDBis a NoSQL database. This is not a database server that requires starting / stopping the server. You can check the tables present in the database or the status of a specific table. eg. CREATE / UPDATE / DELETE / ACTIVE. Tables can only be used if the status of the table is ACTIVE .

-1
source

All Articles