Skip to content

Commit

Permalink
Ability to clear The Graph data (ethereum-optimism#121)
Browse files Browse the repository at this point in the history
* Adding ability to clear The Graph data by setting CLEAR_DATA_KEY environment variable
  • Loading branch information
willmeister authored Apr 29, 2020
1 parent 09a49dc commit 95d9449
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
6 changes: 4 additions & 2 deletions aws/synthetix/prod/web/ecs-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ task_definition:
autoprovision: true
driver: 'local'
- name: postgres-data
scope: task
scope: shared
autoprovision: true
driver: 'local'
- name: ipfs-data
scope: task
scope: shared
autoprovision: true
driver: 'local'
6 changes: 4 additions & 2 deletions aws/synthetix/uat/web/ecs-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ task_definition:
autoprovision: true
driver: 'local'
- name: postgres-data
scope: task
scope: shared
autoprovision: true
driver: 'local'
- name: ipfs-data
scope: task
scope: shared
autoprovision: true
driver: 'local'
19 changes: 19 additions & 0 deletions docker/the-graph/wait-for-ovm.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh
# wait-for-ovm.sh <ovm url with port>
# NOTE: set the CLEAR_DATA_KEY environment variable to clear the /data directory on startup.
# Directory will only be cleared if CLEAR_DATA_KEY is set AND different from last start.

set -e

Expand Down Expand Up @@ -29,6 +31,23 @@ wait_for_server_to_be_reachable()

}

clear_data_if_necessary()
{
DATA_DIRECTORY=${DATA_DIRECTORY:-/data}
CLEAR_DATA_FILE_PATH="$DATA_DIRECTORY/.clear_data_key_$CLEAR_DATA_KEY"

if [[ -n "$CLEAR_DATA_KEY" && ! -f "$CLEAR_DATA_FILE_PATH" ]]; then
echo "Detected change in CLEAR_DATA_KEY. Purging data."
rm -rf ${DATA_DIRECTORY}/*
rm -rf ${DATA_DIRECTORY}/.clear_data_key_*
echo "Local data cleared from '${DATA_DIRECTORY}/*'"
echo "Contents of data dir: $(ls -alh $DATA_DIRECTORY)"
touch $CLEAR_DATA_FILE_PATH
fi
}

clear_data_if_necessary

wait_for_server_to_be_reachable $OVM_URL_WITH_PORT

>&2 echo "OVM is up!"

0 comments on commit 95d9449

Please sign in to comment.