You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/01/01 06:39:28 UTC

[airflow] branch master updated: Allow ./run_tmux.sh script to run standalone (#13420)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 57143d6  Allow ./run_tmux.sh script to run standalone (#13420)
57143d6 is described below

commit 57143d6b7913aeb153feef4c95cae3b8d1bbb614
Author: Kamil BreguĊ‚a <mi...@users.noreply.github.com>
AuthorDate: Fri Jan 1 07:39:12 2021 +0100

    Allow ./run_tmux.sh script to run standalone (#13420)
---
 BREEZE.rst                               |  8 +++-
 scripts/in_container/entrypoint_ci.sh    | 11 +++--
 scripts/in_container/run_tmux.sh         | 72 ++++++++++++++++----------------
 scripts/in_container/run_tmux_welcome.sh |  2 +-
 4 files changed, 51 insertions(+), 42 deletions(-)

diff --git a/BREEZE.rst b/BREEZE.rst
index da7d1ce..d302721 100644
--- a/BREEZE.rst
+++ b/BREEZE.rst
@@ -338,8 +338,12 @@ start integrations (separate Docker images) if specified as extra ``--integratio
 chose which backend database should be used with ``--backend`` flag and python version with ``--python`` flag.
 
 You can also have breeze launch Airflow automatically ``breeze start-airflow``, this will drop you in a
-tmux session with three panes (one to monitor the scheduler, one for the webserver and one with a shell
-for additional commands.
+tmux session with four panes:
+
+   - one to monitor the scheduler,
+   - one for the webserver,
+   - one monitors and compiles Javascript files,
+   - one with a shell for additional commands.
 
 Managing Prod environment (with ``--production-image`` flag):
 
diff --git a/scripts/in_container/entrypoint_ci.sh b/scripts/in_container/entrypoint_ci.sh
index 3630815..06571c4 100755
--- a/scripts/in_container/entrypoint_ci.sh
+++ b/scripts/in_container/entrypoint_ci.sh
@@ -62,6 +62,7 @@ if [[ ${GITHUB_ACTIONS:="false"} == "false" ]]; then
     # Create links for useful CLI tools
     # shellcheck source=scripts/in_container/run_cli_tool.sh
     source <(bash scripts/in_container/run_cli_tool.sh)
+    ln -s '/opt/airflow/scripts/in_container/run_tmux.sh' /usr/bin/run_tmux
 fi
 
 if [[ ${AIRFLOW_VERSION} == *1.10* || ${INSTALL_AIRFLOW_VERSION} == *1.10* ]]; then
@@ -195,11 +196,15 @@ ssh-keyscan -H localhost >> ~/.ssh/known_hosts 2>/dev/null
 # shellcheck source=scripts/in_container/run_init_script.sh
 . "${IN_CONTAINER_DIR}/run_init_script.sh"
 
-# shellcheck source=scripts/in_container/run_tmux.sh
-. "${IN_CONTAINER_DIR}/run_tmux.sh"
-
 cd "${AIRFLOW_SOURCES}"
 
+if [[ ${START_AIRFLOW:="false"} == "true" ]]; then
+    export AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS=${LOAD_DEFAULT_CONNECTIONS}
+    export AIRFLOW__CORE__LOAD_EXAMPLES=${LOAD_EXAMPLES}
+    # shellcheck source=scripts/in_container/run_tmux.sh
+    exec /bin/bash "${IN_CONTAINER_DIR}/run_tmux.sh"
+fi
+
 set +u
 # If we do not want to run tests, we simply drop into bash
 if [[ "${RUN_TESTS}" != "true" ]]; then
diff --git a/scripts/in_container/run_tmux.sh b/scripts/in_container/run_tmux.sh
index d91b3a1..08ed70d 100755
--- a/scripts/in_container/run_tmux.sh
+++ b/scripts/in_container/run_tmux.sh
@@ -15,49 +15,49 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-if [[ ${START_AIRFLOW:="false"} == "true" ]]; then
 
-    ln -s "${IN_CONTAINER_DIR}/stop_tmux_airflow.sh" stop_airflow.sh
-
-    export AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS=${LOAD_DEFAULT_CONNECTIONS}
-    export AIRFLOW__CORE__LOAD_EXAMPLES=${LOAD_EXAMPLES}
-
-    # 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
+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 Bill!
-    export TMUX_TMPDIR=~/.tmux/tmp
-    mkdir -p ~/.tmux/tmp
-    chmod 777 -R ~/.tmux/tmp
+#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
 
-    # Set Session Name
-    export TMUX_SESSION="Airflow"
+# Set Session Name
+export TMUX_SESSION="Airflow"
 
-    # Start New Session with our name
-    tmux new-session -d -s "${TMUX_SESSION}"
+# Start New Session with our name
+tmux new-session -d -s "${TMUX_SESSION}"
 
-    # Name first Pane and start bash
-    tmux rename-window -t 0 'Main'
-    tmux send-keys -t 'Main' 'bash' C-m 'clear' C-m
+# 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 -v
+tmux select-pane -t 1
+tmux send-keys 'airflow scheduler' C-m
 
-    tmux split-window -h
-    tmux select-pane -t 2
-    tmux send-keys 'airflow webserver' C-m
+tmux split-window -h
+tmux select-pane -t 2
+tmux send-keys 'airflow webserver' C-m
 
-    tmux select-pane -t 0
-    tmux split-window -h
-    tmux send-keys 'cd airflow/www/; yarn dev' C-m
+tmux select-pane -t 0
+tmux split-window -h
+tmux send-keys 'cd /opt/airflow/airflow/www/; yarn dev' C-m
 
-    # Attach Session, on the Main window
-    tmux select-pane -t 0
-    tmux send-keys "./scripts/in_container/run_tmux_welcome.sh" C-m
+# 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
-fi
+tmux attach-session -t "${TMUX_SESSION}":0
+rm /usr/local/bin/stop_airflow
diff --git a/scripts/in_container/run_tmux_welcome.sh b/scripts/in_container/run_tmux_welcome.sh
index 8c7015d..976478b 100755
--- a/scripts/in_container/run_tmux_welcome.sh
+++ b/scripts/in_container/run_tmux_welcome.sh
@@ -19,5 +19,5 @@ cd /opt/airflow/ || exit
 clear
 echo "Welcome to your tmux based running Airflow environment (courtesy of Breeze)."
 echo
-echo "     To stop Airflow and exit tmux just './stop_airflow.sh'."
+echo "     To stop Airflow and exit tmux just 'stop_airflow'."
 echo