Subham9126 commited on
Commit
2b79c8b
·
verified ·
1 Parent(s): 518025b

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +16 -8
entrypoint.sh CHANGED
@@ -1,14 +1,21 @@
1
  #!/bin/bash
2
 
3
- # 1. Clone your DAGs repository
4
- # Replace with your repo URL. Use a Personal Access Token (PAT) if private.
5
- echo "Syncing DAGs from GitHub..."
6
- git clone $GIT_REPO_URL /opt/airflow/dags
 
 
 
 
 
7
 
8
- # 2. Initialize or Migrate the External DB
 
9
  airflow db migrate
10
 
11
- # 3. Create Admin User (Optional: only needed if not already in DB)
 
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 Scheduler and Webserver
21
- airflow scheduler & airflow webserver
 
 
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