Advertisement
Guest User

Untitled

a guest
Mar 15th, 2022
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Global defaults and back-compat
  4. : "${AIRFLOW_HOME:="/usr/local/airflow"}"
  5. : "${AIRFLOW__CORE__EXECUTOR:=${EXECUTOR:-Celery}Executor}"
  6. : "${AIRFLOW__CELERY__RESULT_BACKEND:="db+postgresql://airflow:airflow@database:5432/airflow"}"
  7.  
  8.  
  9. export \
  10. AIRFLOW_HOME \
  11. AIRFLOW__CORE__EXECUTOR \
  12. AIRFLOW__CELERY__RESULT_BACKEND \
  13.  
  14. # Waiting for database is ready
  15. DATABASE=$(echo "$AIRFLOW__CORE__SQL_ALCHEMY_CONN" | cut -d '/' -f 3 | cut -d '@' -f 2)
  16. while ! nc -z $DATABASE 5432; do
  17. sleep 3
  18. done
  19.  
  20. # Check the database is created just now
  21. EMPTY=$(python -c "\
  22. import sqlalchemy as sa;\
  23. engine = sa.create_engine('$AIRFLOW__CORE__SQL_ALCHEMY_CONN');\
  24. tables = sa.inspect(engine).get_table_names();
  25. if tables == []: print('empty')\
  26. ")
  27.  
  28. case "$1" in
  29. webserver)
  30. if [ $EMPTY ]; then
  31. echo "Init database"
  32. airflow db init
  33. airflow users create --username admin --firstname admin --lastname admin --role Admin --email [email protected] --password admin
  34. fi
  35. exec airflow webserver
  36. ;;
  37. worker|scheduler)
  38. # Give the webserver time to run initdb.
  39. sleep 10
  40. exec airflow "$@"
  41. ;;
  42. flower)
  43. sleep 10
  44. exec airflow "$@"
  45. ;;
  46. version)
  47. exec airflow "$@"
  48. ;;
  49. *)
  50. # The command is something like bash, not an airflow subcommand. Just run it in the right environment.
  51. exec "$@"
  52. ;;
  53. esac
  54.  
  55. # Create Jupyter notebooks from plain python code for interactive debugging
  56. python ./plugins/utils/converter.py
  57.  
  58. jupyter lab --ip=0.0.0.0 --no-browser --notebook-dir=/tmp/notebooks --ServerApp.base_url=/jupyter/
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement