You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cartodb/wrapper.sh

27 lines
1.1 KiB

#!/bin/sh
rm config/database_*
threads=$1
databaseName="carto_db_test"
dbAdmin="postgres"
lastPort=$((threads + 6000))
startPort=6001
# Iterate and create one database per spec
for i in $(seq $startPort $lastPort)
do
# Get database owner
owner=$(psql -U $dbAdmin -t -c "select r.rolname from pg_database d, pg_roles r where d.datname='carto_db_test' and d.datdba = r.oid")
newDatabase="${databaseName}_${i}";
# Create the database with specific owner and template
$(psql -U $dbAdmin -t -c "create database $newDatabase with owner $owner template $databaseName;") >> wrapper.log 2>&1
# Create the database.yml file
echo "# Creating database_$i.yml file" >> wrapper.log 2>&1
sed -e s/carto_db_test/carto_db_test_$i/g config/database.yml.sample > config/database_$i.yml
# Start Zeus server
TURBO=1 ZEUSSOCK=".zeus$i.sock" RAILS_ENV=test PARALLEL=true RAILS_DATABASE_FILE=database_$i.yml REDIS_PORT=$i bundle exec zeus --config zeus_test.json start >/dev/null 2>/dev/null &
done
touch specfailed.log
touch specsuccess.log
echo "# Wrapper finished"