ipld-eth-server/dockerfiles/super_node/entrypoint.sh

60 lines
1.4 KiB
Bash
Raw Normal View History

2020-03-23 18:05:39 +00:00
#!/bin/sh
2020-06-30 00:16:52 +00:00
# Runs the db migrations and starts the watcher services
2020-03-23 18:05:39 +00:00
# Exit if the variable tests fail
set -e
set +x
# Check the database variables are set
# XXX set defaults, don't silently fail
#test $DATABASE_HOSTNAME
#test $DATABASE_NAME
#test $DATABASE_PORT
#test $DATABASE_USER
#test $DATABASE_PASSWORD
#test $IPFS_INIT
#test $IPFS_PATH
2020-06-30 00:16:52 +00:00
VDB_COMMAND=${VDB_COMMAND:-watch}
2020-03-23 18:05:39 +00:00
set +e
# Construct the connection string for postgres
VDB_PG_CONNECT=postgresql://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOSTNAME:$DATABASE_PORT/$DATABASE_NAME?sslmode=disable
# Run the DB migrations
echo "Connecting with: $VDB_PG_CONNECT"
echo "Running database migrations"
./goose -dir migrations/vulcanizedb postgres "$VDB_PG_CONNECT" up
rv=$?
if [ $rv != 0 ]; then
echo "Could not run migrations. Are the database details correct?"
exit 1
fi
2020-05-01 15:49:07 +00:00
2020-03-25 20:14:48 +00:00
echo "Beginning the vulcanizedb process"
VDB_CONFIG_FILE=${VDB_CONFIG_FILE:-config.toml}
DEFAULT_OPTIONS="--config=$VDB_CONFIG_FILE"
VDB_FULL_CL=${VDB_FULL_CL:-$VDB_COMMAND $DEFAULT_OPTIONS}
echo running: ./ipfs-blockchain-watcher $VDB_FULL_CL $@
2020-03-25 20:14:48 +00:00
2020-05-01 15:49:07 +00:00
case "$1" in
"/bin/sh" )
echo dropping to shell
exec /bin/sh
esac
2020-04-04 20:31:45 +00:00
vdb_args="$@"
# default is to use the config passed by the build arg
2020-05-01 15:49:07 +00:00
if [[ -z "$vdb_args" ]]; then
2020-04-04 20:31:45 +00:00
vdb_args="--config=config.toml"
fi
echo running: ./ipfs-blockchain-watcher $vdb_args
./ipfs-blockchain-watcher $vdb_args
2020-03-23 18:05:39 +00:00
rv=$?
if [ $rv != 0 ]; then
echo "VulcanizeDB startup failed"
exit 1
fi