Created
January 15, 2020 21:36
-
-
Save alevene/5a926699d01dcf2cae56c210601bb5d9 to your computer and use it in GitHub Desktop.
Airflow install restart containers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# completely rebuild airflow containers. See below for switches | |
THIS_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"; readonly THIS_SCRIPT_DIR | |
THIS_GIT_ROOT="$(cd "$THIS_SCRIPT_DIR" && git rev-parse --show-toplevel)"; readonly THIS_GIT_ROOT | |
DAGS_GIT_ROOT="$(cd "$THIS_GIT_ROOT/../airflow-dags" && git rev-parse --show-toplevel)"; readonly DAGS_GIT_ROOT | |
switches="${1}" | |
# use keep_dag_list file to drive the lis tof dags to keep. this cuts down on the dag load time and ui real estate | |
if [[ $switches =~ .*d.* ]]; then | |
cat "${DAGS_GIT_ROOT}"/.mine/keep_dag_list | xargs "${DAGS_GIT_ROOT}"/.mine/ignore_all_but | |
fi | |
# keep the db up (assumes functionality from al-keep-dev-db branch) | |
if [[ $switches =~ .*k.* ]]; then | |
destroy_opt="--keep-db" | |
skip_opt="--skip-existing-containers" | |
fi | |
"${THIS_GIT_ROOT}"/stop_dev_env | |
"${THIS_GIT_ROOT}"/destroy_dev_env $destroy_opt | |
"${THIS_GIT_ROOT}"/build | |
"${THIS_GIT_ROOT}"/create_dev_env --debug $skip_opt | |
"${THIS_GIT_ROOT}"/start_dev_env | |
sleep 60 | |
# start the airflow config DAG | |
if [[ $switches =~ .*s.* ]]; then | |
docker exec -it airflow-dev-db psql -U postgres -d airflow -c "UPDATE dag SET is_paused = false WHERE dag_id LIKE 'airflow_config_v01';" | |
fi | |
sleep 5 | |
# open up the UI | |
if [[ $switches =~ .*w.* ]]; then | |
"${THIS_GIT_ROOT}"/webserver/open-website | |
fi | |
# enter the worker container | |
if [[ $switches =~ .*c.* ]]; then | |
docker exec -it airflow-dev-worker bash | |
fi | |
# set aws creds via okta | |
if [[ $switches =~ .*a.* ]]; then | |
"${THIS_GIT_ROOT}"/.mine/push_aws_creds | |
fi | |
#"${THIS_GIT_ROOT}"/postgres/exec ./create_database dewey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment