| #!/usr/bin/env bash |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| if [ ! -e /usr/local/bin/stop_airflow ]; then |
| ln -s "/opt/airflow/scripts/in_container/stop_tmux_airflow.sh" /usr/local/bin/stop_airflow || true |
| fi |
| # Use LocalExecutor if not set and if backend is not sqlite as it gives |
| # better performance |
| if [[ ${BACKEND} != "sqlite" ]]; then |
| export AIRFLOW__CORE__EXECUTOR=${AIRFLOW__CORE__EXECUTOR:-LocalExecutor} |
| fi |
| |
| #this is because I run docker in WSL - Hi Nadella! |
| export TMUX_TMPDIR=~/.tmux/tmp |
| if [ -e ~/.tmux/tmp ]; then |
| rm -rf ~/.tmux/tmp |
| fi |
| mkdir -p ~/.tmux/tmp |
| chmod 777 -R ~/.tmux/tmp |
| |
| # Creating a new tmux session (below) will start a new login shell and /etc/profile |
| # will overwrite the custom Dockerfile PATH variable. Adding the custom PATH export |
| # to home directory profile here will take precedence. |
| echo "export PATH=$PATH" >> ~/.profile |
| |
| # Set Session Name |
| export TMUX_SESSION="Airflow" |
| |
| # Start New Session with our name |
| tmux new-session -d -s "${TMUX_SESSION}" |
| |
| # Enable mouse interaction with tmux. This allows selecting between the panes |
| # by clicking with the mouse and also allows scrolling back through terminal |
| # output with the mouse wheel. |
| tmux set mouse on |
| |
| # Name first Pane and start bash |
| tmux rename-window -t 0 'Main' |
| tmux send-keys -t 'Main' 'bash' C-m 'clear' C-m |
| |
| tmux split-window -v |
| tmux select-pane -t 1 |
| tmux send-keys 'airflow scheduler' C-m |
| |
| tmux split-window -h |
| tmux select-pane -t 2 |
| if [[ ${DEV_MODE=} == "true" ]]; then |
| tmux send-keys 'airflow webserver -d' C-m |
| else |
| tmux send-keys 'airflow webserver' C-m |
| fi |
| if python -c 'import sys; sys.exit(sys.version_info < (3, 7))'; then |
| tmux select-pane -t 0 |
| tmux split-window -h |
| tmux send-keys 'airflow triggerer' C-m |
| fi |
| |
| # Attach Session, on the Main window |
| tmux select-pane -t 0 |
| tmux send-keys "/opt/airflow/scripts/in_container/run_tmux_welcome.sh" C-m |
| |
| tmux attach-session -t "${TMUX_SESSION}":0 |
| rm /usr/local/bin/stop_airflow |