Spaces:
Sleeping
Sleeping
Update entrypoint.sh
Browse files- entrypoint.sh +16 -8
entrypoint.sh
CHANGED
|
@@ -1,14 +1,21 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
# 1.
|
| 4 |
-
|
| 5 |
-
echo "
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
# 2. Initialize
|
|
|
|
| 9 |
airflow db migrate
|
| 10 |
|
| 11 |
-
# 3. Create Admin
|
|
|
|
| 12 |
airflow users create \
|
| 13 |
--username "$ADMIN_USER" \
|
| 14 |
--password "$ADMIN_PASSWORD" \
|
|
@@ -17,5 +24,6 @@ airflow users create \
|
|
| 17 |
--role Admin \
|
| 18 |
--email admin@example.com || true
|
| 19 |
|
| 20 |
-
# 4. Start
|
| 21 |
-
|
|
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
# 1. Clean and Sync DAGs
|
| 4 |
+
if [ -d "/opt/airflow/dags/.git" ]; then
|
| 5 |
+
echo "Updating existing DAGs repo..."
|
| 6 |
+
cd /opt/airflow/dags && git pull
|
| 7 |
+
else
|
| 8 |
+
echo "Cloning DAGs from GitHub..."
|
| 9 |
+
rm -rf /opt/airflow/dags/* # Ensure folder is empty
|
| 10 |
+
git clone $GIT_REPO_URL /opt/airflow/dags
|
| 11 |
+
fi
|
| 12 |
|
| 13 |
+
# 2. Initialize/Migrate DB (The most time-consuming part)
|
| 14 |
+
echo "Running DB migrations..."
|
| 15 |
airflow db migrate
|
| 16 |
|
| 17 |
+
# 3. Create Admin (Added '|| true' so it doesn't crash if user exists)
|
| 18 |
+
echo "Checking for admin user..."
|
| 19 |
airflow users create \
|
| 20 |
--username "$ADMIN_USER" \
|
| 21 |
--password "$ADMIN_PASSWORD" \
|
|
|
|
| 24 |
--role Admin \
|
| 25 |
--email admin@example.com || true
|
| 26 |
|
| 27 |
+
# 4. Start
|
| 28 |
+
echo "Starting Scheduler and Webserver..."
|
| 29 |
+
airflow scheduler & exec airflow webserver
|