#!/bin/bash if [[ -d "$OUT_DIR" ]] then echo "found existing IMPORT DIR cleaning up..." rm -rf "$OUT_DIR" mkdir -p "$OUT_DIR" else echo "IMPORT DIR does not exist creating it." mkdir -p "$OUT_DIR" fi # using timeout because the timeout flag for celery inspect does not work timeout 5 celery inspect ping -b "$CELERY_BROKER_URL" if [[ $? -eq 124 ]] then >&2 echo "Celery workers not available. Is the CELERY_BROKER_URL ($CELERY_BROKER_URL) correct?" exit 1 fi echo "Creating seed data..." python create_import_users.py -vv -c "$CONFIG" --dir "$OUT_DIR" "$NUMBER_OF_USERS" wait $! echo "Check for running celery workers ..." if [ -f ./cic-ussd-import.pid ]; then echo "Found a running worker. Killing ..." kill -9 $( nohup.out 2> nohup.err < /dev/null & else echo "Running worker with opening balance transactions" TARGET_TX_COUNT=$((NUMBER_OF_USERS*2)) nohup python cic_ussd/import_balance.py -vv -c "$CONFIG" -p "$ETH_PROVIDER" -r "$CIC_REGISTRY_ADDRESS" --include-balances --token-symbol "$TOKEN_SYMBOL" -y "$KEYSTORE_PATH" "$OUT_DIR" & fi echo "Target count set to ${TARGET_TX_COUNT}" until [ -f ./cic-import-ussd.pid ] do echo "Polling for celery worker pid file..." sleep 1 done IMPORT_BALANCE_JOB=$(