dd
Browse files- backend/celery_tasks/schedule_loader.py +3 -0
- start_app.py +6 -6
backend/celery_tasks/schedule_loader.py
CHANGED
|
@@ -64,6 +64,7 @@ def load_schedules_task():
|
|
| 64 |
This task runs every 5 minutes to check for new or updated schedules.
|
| 65 |
"""
|
| 66 |
try:
|
|
|
|
| 67 |
logger.info("Loading schedules from database...")
|
| 68 |
|
| 69 |
# Get Supabase configuration
|
|
@@ -84,6 +85,7 @@ def load_schedules_task():
|
|
| 84 |
)
|
| 85 |
|
| 86 |
schedules = response.data if response.data else []
|
|
|
|
| 87 |
logger.info(f"Found {len(schedules)} schedules")
|
| 88 |
|
| 89 |
# Get current beat schedule
|
|
@@ -147,6 +149,7 @@ def load_schedules_task():
|
|
| 147 |
|
| 148 |
# Update the beat schedule
|
| 149 |
current_app.conf.beat_schedule = new_schedule
|
|
|
|
| 150 |
logger.info("Updated Celery Beat schedule")
|
| 151 |
|
| 152 |
return {
|
|
|
|
| 64 |
This task runs every 5 minutes to check for new or updated schedules.
|
| 65 |
"""
|
| 66 |
try:
|
| 67 |
+
print(f"[CELERY BEAT] Loading schedules from database at {datetime.now()}...")
|
| 68 |
logger.info("Loading schedules from database...")
|
| 69 |
|
| 70 |
# Get Supabase configuration
|
|
|
|
| 85 |
)
|
| 86 |
|
| 87 |
schedules = response.data if response.data else []
|
| 88 |
+
print(f"[CELERY BEAT] Found {len(schedules)} schedules in database")
|
| 89 |
logger.info(f"Found {len(schedules)} schedules")
|
| 90 |
|
| 91 |
# Get current beat schedule
|
|
|
|
| 149 |
|
| 150 |
# Update the beat schedule
|
| 151 |
current_app.conf.beat_schedule = new_schedule
|
| 152 |
+
print(f"[CELERY BEAT] Successfully updated Celery Beat schedule with {len(new_schedule)} jobs")
|
| 153 |
logger.info("Updated Celery Beat schedule")
|
| 154 |
|
| 155 |
return {
|
start_app.py
CHANGED
|
@@ -51,19 +51,19 @@ def start_celery_components():
|
|
| 51 |
]
|
| 52 |
|
| 53 |
if platform.system() == "Windows":
|
| 54 |
-
# Windows: Use subprocess to start background processes
|
| 55 |
subprocess.Popen(worker_cmd, cwd=backend_dir,
|
| 56 |
-
stdout=
|
| 57 |
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
|
| 58 |
subprocess.Popen(beat_cmd, cwd=backend_dir,
|
| 59 |
-
stdout=
|
| 60 |
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
|
| 61 |
else:
|
| 62 |
-
# Linux/Mac: Use subprocess with
|
| 63 |
subprocess.Popen(worker_cmd, cwd=backend_dir,
|
| 64 |
-
stdout=
|
| 65 |
subprocess.Popen(beat_cmd, cwd=backend_dir,
|
| 66 |
-
stdout=
|
| 67 |
|
| 68 |
print("Celery worker and beat scheduler started in background")
|
| 69 |
time.sleep(2) # Give Celery components time to start
|
|
|
|
| 51 |
]
|
| 52 |
|
| 53 |
if platform.system() == "Windows":
|
| 54 |
+
# Windows: Use subprocess to start background processes with visible logs
|
| 55 |
subprocess.Popen(worker_cmd, cwd=backend_dir,
|
| 56 |
+
stdout=sys.stdout, stderr=sys.stderr,
|
| 57 |
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
|
| 58 |
subprocess.Popen(beat_cmd, cwd=backend_dir,
|
| 59 |
+
stdout=sys.stdout, stderr=sys.stderr,
|
| 60 |
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
|
| 61 |
else:
|
| 62 |
+
# Linux/Mac: Use subprocess with visible logs
|
| 63 |
subprocess.Popen(worker_cmd, cwd=backend_dir,
|
| 64 |
+
stdout=sys.stdout, stderr=sys.stderr)
|
| 65 |
subprocess.Popen(beat_cmd, cwd=backend_dir,
|
| 66 |
+
stdout=sys.stdout, stderr=sys.stderr)
|
| 67 |
|
| 68 |
print("Celery worker and beat scheduler started in background")
|
| 69 |
time.sleep(2) # Give Celery components time to start
|