Spaces:
Sleeping
Sleeping
| # v7 — Process-safe launcher | |
| cd /usr/local/searxng | |
| # Patch settings (same logic as your old run.sh but simplified) | |
| python3 << 'PYEOF' | |
| import secrets, os | |
| f = os.environ.get("SEARXNG_SETTINGS_PATH", "/etc/searxng/settings.yml") | |
| if not os.path.exists(f): | |
| f = "searx/settings.yml" | |
| lines = open(f).readlines() | |
| output = [] | |
| json_added = False | |
| for line in lines: | |
| s = line.strip() | |
| if "ultrasecretkey" in line: | |
| line = line.replace("ultrasecretkey", secrets.token_hex(32)) | |
| if s.startswith("port:") and "8080" in s: | |
| line = line.replace("8080", "7860") | |
| if "bind_address" in s and "127.0.0.1" in s: | |
| line = line.replace("127.0.0.1", "0.0.0.0") | |
| if s.startswith("limiter:") and "true" in s: | |
| line = line.replace("true", "false") | |
| if s.startswith("image_proxy:") and "true" in s: | |
| line = line.replace("true", "false") | |
| if s == "- html" and not json_added: | |
| output.append(line) | |
| indent = line[:len(line) - len(line.lstrip())] | |
| output.append(f"{indent}- json\n") | |
| json_added = True | |
| continue | |
| output.append(line) | |
| open(f, "w").writelines(output) | |
| print(f"Settings patched, json_format={json_added}") | |
| PYEOF | |
| echo "Starting engine on port 7860..." | |
| # Run via werkzeug — process name is "python3", not "searxng" or "granian" | |
| exec python3 -c " | |
| import os | |
| os.environ['SEARXNG_SETTINGS_PATH'] = '/etc/searxng/settings.yml' | |
| os.chdir('/usr/local/searxng') | |
| from searx.webapp import app | |
| from werkzeug.serving import run_simple | |
| run_simple('0.0.0.0', 7860, app, threaded=True, use_reloader=False) | |
| " | |