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

64 lines
1.7 KiB
Bash
Raw Normal View History

2019-06-14 02:12:56 +00:00
#!/bin/sh
# Runs the db migrations and starts the super node services
# Exit if the variable tests fail
set -e
# Check the database variables are set
2019-06-14 02:12:56 +00:00
test $VDB_PG_NAME
test $VDB_PG_HOSTNAME
test $VDB_PG_PORT
test $VDB_PG_USER
2020-01-27 20:13:54 +00:00
test $IPFS_INIT
2019-06-14 02:12:56 +00:00
set +e
# Export our database variables so that the IPFS Postgres plugin can use them
2019-06-14 02:12:56 +00:00
export IPFS_PGHOST=$VDB_PG_HOSTNAME
export IPFS_PGUSER=$VDB_PG_USER
export IPFS_PGDATABASE=$VDB_PG_NAME
export IPFS_PGPORT=$VDB_PG_PORT
export IPFS_PGPASSWORD=$VDB_PG_PASSWORD
# Construct the connection string for postgres
2019-06-14 02:12:56 +00:00
VDB_PG_CONNECT=postgresql://$VDB_PG_USER:$VDB_PG_PASSWORD@$VDB_PG_HOSTNAME:$VDB_PG_PORT/$VDB_PG_NAME?sslmode=disable
# Run the DB migrations
2019-06-14 02:12:56 +00:00
echo "Connecting with: $VDB_PG_CONNECT"
echo "Running database migrations"
./goose -dir migrations/vulcanizedb postgres "$VDB_PG_CONNECT" up
2020-01-27 20:13:54 +00:00
2019-06-14 02:12:56 +00:00
# If the db migrations ran without err
2020-01-27 20:13:54 +00:00
if [[ $? -eq 0 ]]; then
# and IPFS_INIT is true
if [[ "$IPFS_INIT" = true ]] ; then
# initialize PG-IPFS
echo "Initializing Postgres-IPFS profile"
./ipfs init --profile=postgresds
else
echo "IPFS profile already initialized, skipping initialization"
fi
else
2019-06-14 02:12:56 +00:00
echo "Could not run migrations. Are the database details correct?"
exit
fi
2019-06-14 02:12:56 +00:00
# If IPFS initialization was successful
2020-01-27 20:13:54 +00:00
if [[ $? -eq 0 ]]; then
2020-03-02 22:30:46 +00:00
echo "Beginning the vulcanizedb super node process"
./vulcanizedb superNode --config=config.toml 2>&1 | tee -a vulcanizedb.log &
2019-06-14 02:12:56 +00:00
else
2020-03-02 22:30:46 +00:00
echo "Could not initialize IPFS."
2019-06-14 02:12:56 +00:00
exit
fi
# If Vulcanizedb startup was successful
if [ $? -eq 0 ]; then
echo "Seed node successfully booted"
else
echo "Could not start vulcanizedb syncPublishScreenAndServe process. Is the config file correct?"
exit
fi
2020-03-02 22:30:46 +00:00
tail -f vulcanizedb.log