Subham9126 commited on
Commit
6c38db9
·
verified ·
1 Parent(s): 051eca4

Rename entrypoint.sh to startup.sh

Browse files
Files changed (2) hide show
  1. entrypoint.sh +0 -31
  2. startup.sh +30 -0
entrypoint.sh DELETED
@@ -1,31 +0,0 @@
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" \
22
- --firstname Admin \
23
- --lastname User \
24
- --role Admin \
25
- --email admin@example.com || true
26
-
27
- # 4. Start
28
- # ... rest of your script ...
29
- echo "Starting Scheduler and Webserver..."
30
- airflow scheduler &
31
- exec airflow webserver --port 7860 --hostname 0.0.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
startup.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ echo "==> Syncing DAGs from GitHub..."
5
+ rm -rf /opt/airflow/dags
6
+ git clone "${GIT_REPO_URL}" /opt/airflow/dags 2>/dev/null
7
+
8
+ echo "==> Running DB migrate..."
9
+ airflow db migrate > /dev/null 2>&1
10
+
11
+ echo "==> Creating admin user..."
12
+ airflow users create \
13
+ --username "${ADMIN_USER}" \
14
+ --password "${ADMIN_PASSWORD}" \
15
+ --firstname Admin \
16
+ --lastname User \
17
+ --role Admin \
18
+ --email admin@airflow.com > /dev/null 2>&1 || true
19
+
20
+ echo "==> Starting scheduler..."
21
+ airflow scheduler > /dev/null 2>&1 &
22
+
23
+ echo "==> Starting periodic git sync..."
24
+ (while true; do
25
+ sleep 60
26
+ git -C /opt/airflow/dags pull --quiet > /dev/null 2>&1
27
+ done) &
28
+
29
+ echo "==> Starting webserver on :7860"
30
+ exec airflow webserver --port 7860 > /dev/null 2>&1