diff --git a/.gitlab-ci.yaml b/.gitlab-ci.yaml index 7f0e3ea418b13367aa8400dba8e7d2e86f5ed6b1..5f60fa52f69b64afd054684040f9270343aaf2c8 100644 --- a/.gitlab-ci.yaml +++ b/.gitlab-ci.yaml @@ -269,6 +269,9 @@ sync_e2e_benchmark: ci/wait-for-postgres.sh ${HAF_ADMIN_POSTGRES_URL} && \ cd ${WORKING_DIR} && \ cat ${WORKING_DIR}/.hivemind-venv/lib/python3.8/site-packages/hive/_version.py > version.log && \ + /home/hivemind/docker_entrypoint.sh setup \ + --database-admin-url="${HAF_ADMIN_POSTGRES_URL}" \ + --add-mocks=${ADD_MOCKS} && \ ${WORKING_DIR}/docker_entrypoint.sh sync \ --log-mask-sensitive-data \ --pid-file hive_sync.pid \ @@ -276,7 +279,6 @@ sync_e2e_benchmark: --test-profile=False \ --prometheus-port 11011 \ --database-url="${HAF_POSTGRES_URL}" \ - --database-admin-url="${HAF_ADMIN_POSTGRES_URL}" \ --community-start-block 4998000 && \ ${WORKING_DIR}/app/ci/collect-db-stats.sh && \ python -m http.server ${RUNNER_HIVEMIND_SERVER_HTTP_PORT} diff --git a/README.md b/README.md index 3c47c1f9b9544f0d48b922718aa830bba821e0be..0d4140984fe8d8f44efa7047318f0fb1aabeb357 100644 --- a/README.md +++ b/README.md @@ -185,14 +185,18 @@ Entering application main loop... #### Running Hivemind instance container -The built Hivemind instance requires a preconfigured HAF database to store its data. The required database configuration will be performed automatically by the container before the `hive sync` command is run: +The built Hivemind instance requires a preconfigured HAF database to store its data. You can perform them with `setup` command before starting the sync. The commands below assume that the running HAF container has IP: 172.17.0.2 ```bash -../hivemind/scripts/run_instance.sh registry.gitlab.syncad.com/hive/hivemind/instance:local sync \ - --database-url="postgresql://haf_app_admin@172.17.0.2:5432/haf_block_log" \ +# Set-up Database +../hivemind/scripts/run_instance.sh registry.gitlab.syncad.com/hive/hivemind/instance:local setup \ --database-admin-url="postgresql://haf_admin@172.17.0.2/haf_block_log" # haf_admin access URL + +# Run the sync +../hivemind/scripts/run_instance.sh registry.gitlab.syncad.com/hive/hivemind/instance:local sync \ + --database-url="postgresql://haf_app_admin@172.17.0.2:5432/haf_block_log" ``` ## Updating from an existing hivemind database diff --git a/docker/docker_entrypoint.sh b/docker/docker_entrypoint.sh index df0023a64c26c4ed1d6ad2b6b6288b6c7017e48d..d06eef49d59981a3deea8553173012014655afde 100755 --- a/docker/docker_entrypoint.sh +++ b/docker/docker_entrypoint.sh @@ -27,8 +27,14 @@ while [ $# -gt 0 ]; do --database-admin-url=*) POSTGRES_ADMIN_URL="${1#*=}" ;; + --add-mocks=*) + ADD_MOCKS="${1#*=}" + ;; + --add-mocks) + ADD_MOCKS=true + ;; *) - HIVEMIND_ARGS+=("$1") + HIVEMIND_ARGS+=("$1") esac shift done @@ -48,24 +54,23 @@ run_hive() { fi } -sync() { - log "sync" "Setting up the database before sync..." +setup() { + log "setup" "Setting up the database..." cd /home/hivemind/app - ./setup_postgres.sh --postgres-url="${POSTGRES_URL}" + ./setup_postgres.sh --postgres-url="${POSTGRES_ADMIN_URL}" ./setup_db.sh --postgres-url="${POSTGRES_ADMIN_URL}" if [[ "$ADD_MOCKS" == "true" ]]; then - log "sync" "Adding mocks to database..." + log "setup" "Adding mocks to database..." # shellcheck source=/dev/null source /home/hivemind/.hivemind-venv/bin/activate ci/add-mocks-to-db.sh --postgres-url="${POSTGRES_ADMIN_URL}" deactivate fi - run_hive } case "$COMMAND" in - sync) - sync + setup) + setup ;; *) run_hive