Z User commited on
Commit
4c14cbd
·
1 Parent(s): 1054555

fix(entrypoint): start the celery worker only when CELERY_BULK_ENABLED=true — a misconfigured rediss:// broker caused a pointless 5s crash-restart loop while bulk actually runs sync

Browse files
Files changed (1) hide show
  1. entrypoint.py +16 -2
entrypoint.py CHANGED
@@ -208,8 +208,22 @@ def main():
208
  signal.signal(signal.SIGTERM, on_signal)
209
  signal.signal(signal.SIGINT, on_signal)
210
 
211
- if broker_url:
 
 
 
 
 
 
 
 
212
  spawn("worker")
 
 
 
 
 
 
213
  web = spawn("web")
214
 
215
  while not state["stopping"]:
@@ -221,7 +235,7 @@ def main():
221
  time.sleep(2)
222
  if not state["stopping"]:
223
  spawn("redis")
224
- if broker_url and children["worker"].poll() is not None:
225
  print(f"[ENTRYPOINT] worker exited ({children['worker'].returncode}) - restarting in 5s", flush=True)
226
  time.sleep(5)
227
  if not state["stopping"]:
 
208
  signal.signal(signal.SIGTERM, on_signal)
209
  signal.signal(signal.SIGINT, on_signal)
210
 
211
+ # Celery worker (bulk validation queue) starts ONLY when bulk is routed
212
+ # through Celery on this host. With CELERY_BULK_ENABLED=false (the Space
213
+ # default) bulk runs synchronously in-process, and spawning a worker
214
+ # against a misconfigured broker (e.g. a rediss:// URL without
215
+ # ssl_cert_reqs) produced a pointless 5s crash-restart loop.
216
+ run_celery_worker = (
217
+ os.environ.get("CELERY_BULK_ENABLED", "").strip().lower() in ("1", "true", "yes")
218
+ )
219
+ if broker_url and run_celery_worker:
220
  spawn("worker")
221
+ elif broker_url:
222
+ print(
223
+ "[ENTRYPOINT] CELERY_BULK_ENABLED!=true — bulk runs sync; "
224
+ "celery worker NOT started",
225
+ flush=True,
226
+ )
227
  web = spawn("web")
228
 
229
  while not state["stopping"]:
 
235
  time.sleep(2)
236
  if not state["stopping"]:
237
  spawn("redis")
238
+ if run_celery_worker and broker_url and children.get("worker") and children["worker"].poll() is not None:
239
  print(f"[ENTRYPOINT] worker exited ({children['worker'].returncode}) - restarting in 5s", flush=True)
240
  time.sleep(5)
241
  if not state["stopping"]: