Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to clear The Graph data #121

Merged
merged 3 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always forget that * doesn't apply to dot files!

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks right to me!


wait_for_server_to_be_reachable $OVM_URL_WITH_PORT

>&2 echo "OVM is up!"