Buffy commited on
Commit
79019c5
·
1 Parent(s): 42f6abb

Surface searxng bootstrap errors in status route

Browse files
Files changed (2) hide show
  1. searx_bridge.py +1 -0
  2. searx_runtime.py +11 -2
searx_bridge.py CHANGED
@@ -22,6 +22,7 @@ def register_routes(fa_app):
22
  return JSONResponse({
23
  "runtime_dir": searx_runtime.RUNTIME_DIR,
24
  "installed": searx_runtime.searxng_ready(),
 
25
  "port": searx_runtime.SEARXNG_PORT,
26
  })
27
 
 
22
  return JSONResponse({
23
  "runtime_dir": searx_runtime.RUNTIME_DIR,
24
  "installed": searx_runtime.searxng_ready(),
25
+ "boot_error": searx_runtime.boot_error(),
26
  "port": searx_runtime.SEARXNG_PORT,
27
  })
28
 
searx_runtime.py CHANGED
@@ -37,6 +37,7 @@ SETTINGS_FILE = os.path.join(ROOT, "searxng_settings.yml")
37
  _proc = None
38
  _lock = threading.Lock()
39
  _ready = threading.Event()
 
40
 
41
 
42
  def _log(msg):
@@ -109,15 +110,19 @@ def start_searxng() -> bool:
109
  with _lock:
110
  if _proc and _proc.poll() is None:
111
  return True
 
112
  try:
113
  if not _fetch_source():
114
- _log("source fetch failed")
 
115
  return False
116
  py = _venv_python()
117
  if not py:
 
118
  return False
119
  except Exception as e:
120
- _log(f"bootstrap failed: {e}")
 
121
  return False
122
  env = os.environ.copy()
123
  env["SEARXNG_SETTINGS_PATH"] = SETTINGS_FILE
@@ -149,3 +154,7 @@ def _pump_logs():
149
 
150
  def searxng_ready() -> bool:
151
  return _ready.is_set()
 
 
 
 
 
37
  _proc = None
38
  _lock = threading.Lock()
39
  _ready = threading.Event()
40
+ _boot_error = ""
41
 
42
 
43
  def _log(msg):
 
110
  with _lock:
111
  if _proc and _proc.poll() is None:
112
  return True
113
+ global _boot_error
114
  try:
115
  if not _fetch_source():
116
+ _boot_error = "source fetch failed"
117
+ _log(_boot_error)
118
  return False
119
  py = _venv_python()
120
  if not py:
121
+ _boot_error = "venv/pip install failed (see logs)"
122
  return False
123
  except Exception as e:
124
+ _boot_error = f"bootstrap failed: {e}"
125
+ _log(_boot_error)
126
  return False
127
  env = os.environ.copy()
128
  env["SEARXNG_SETTINGS_PATH"] = SETTINGS_FILE
 
154
 
155
  def searxng_ready() -> bool:
156
  return _ready.is_set()
157
+
158
+
159
+ def boot_error() -> str:
160
+ return _boot_error