Skip to content
Snippets Groups Projects
Verified Commit f36f1eb0 authored by Konrad Botor's avatar Konrad Botor
Browse files

Updated Docker entrypoint script to split database setup from sync command - ref. #198

parent 3be421a2
No related branches found
No related tags found
2 merge requests!827Merge develop changes to master,!594CI testing should use build instance sh and built image during 5m testing
...@@ -269,6 +269,9 @@ sync_e2e_benchmark: ...@@ -269,6 +269,9 @@ sync_e2e_benchmark:
ci/wait-for-postgres.sh ${HAF_ADMIN_POSTGRES_URL} && \ ci/wait-for-postgres.sh ${HAF_ADMIN_POSTGRES_URL} && \
cd ${WORKING_DIR} && \ cd ${WORKING_DIR} && \
cat ${WORKING_DIR}/.hivemind-venv/lib/python3.8/site-packages/hive/_version.py > version.log && \ 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 \ ${WORKING_DIR}/docker_entrypoint.sh sync \
--log-mask-sensitive-data \ --log-mask-sensitive-data \
--pid-file hive_sync.pid \ --pid-file hive_sync.pid \
...@@ -276,7 +279,6 @@ sync_e2e_benchmark: ...@@ -276,7 +279,6 @@ sync_e2e_benchmark:
--test-profile=False \ --test-profile=False \
--prometheus-port 11011 \ --prometheus-port 11011 \
--database-url="${HAF_POSTGRES_URL}" \ --database-url="${HAF_POSTGRES_URL}" \
--database-admin-url="${HAF_ADMIN_POSTGRES_URL}" \
--community-start-block 4998000 && \ --community-start-block 4998000 && \
${WORKING_DIR}/app/ci/collect-db-stats.sh && \ ${WORKING_DIR}/app/ci/collect-db-stats.sh && \
python -m http.server ${RUNNER_HIVEMIND_SERVER_HTTP_PORT} python -m http.server ${RUNNER_HIVEMIND_SERVER_HTTP_PORT}
......
...@@ -185,14 +185,18 @@ Entering application main loop... ...@@ -185,14 +185,18 @@ Entering application main loop...
#### Running Hivemind instance container #### 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 The commands below assume that the running HAF container has IP: 172.17.0.2
```bash ```bash
../hivemind/scripts/run_instance.sh registry.gitlab.syncad.com/hive/hivemind/instance:local sync \ # Set-up Database
--database-url="postgresql://haf_app_admin@172.17.0.2:5432/haf_block_log" \ ../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 --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 ## Updating from an existing hivemind database
......
...@@ -27,8 +27,14 @@ while [ $# -gt 0 ]; do ...@@ -27,8 +27,14 @@ while [ $# -gt 0 ]; do
--database-admin-url=*) --database-admin-url=*)
POSTGRES_ADMIN_URL="${1#*=}" POSTGRES_ADMIN_URL="${1#*=}"
;; ;;
--add-mocks=*)
ADD_MOCKS="${1#*=}"
;;
--add-mocks)
ADD_MOCKS=true
;;
*) *)
HIVEMIND_ARGS+=("$1") HIVEMIND_ARGS+=("$1")
esac esac
shift shift
done done
...@@ -48,24 +54,23 @@ run_hive() { ...@@ -48,24 +54,23 @@ run_hive() {
fi fi
} }
sync() { setup() {
log "sync" "Setting up the database before sync..." log "setup" "Setting up the database..."
cd /home/hivemind/app 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}" ./setup_db.sh --postgres-url="${POSTGRES_ADMIN_URL}"
if [[ "$ADD_MOCKS" == "true" ]]; then if [[ "$ADD_MOCKS" == "true" ]]; then
log "sync" "Adding mocks to database..." log "setup" "Adding mocks to database..."
# shellcheck source=/dev/null # shellcheck source=/dev/null
source /home/hivemind/.hivemind-venv/bin/activate source /home/hivemind/.hivemind-venv/bin/activate
ci/add-mocks-to-db.sh --postgres-url="${POSTGRES_ADMIN_URL}" ci/add-mocks-to-db.sh --postgres-url="${POSTGRES_ADMIN_URL}"
deactivate deactivate
fi fi
run_hive
} }
case "$COMMAND" in case "$COMMAND" in
sync) setup)
sync setup
;; ;;
*) *)
run_hive run_hive
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment