SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[mod] make run: start granian server and versioning by Dependabot (#5037)
Markus Heiser168fa9b09bc8
diff --git a/container/Dockerfile b/container/Dockerfileindex 83fe3b999..9da444a0d 100644--- a/container/Dockerfile+++ b/container/Dockerfile@@ -1,11 +1,11 @@FROM ghcr.io/searxng/base:searxng-builder AS builder-COPY ./requirements.txt ./requirements.txt+COPY ./requirements*.txt ./RUN --mount=type=cache,id=pip,target=/root/.cache/pip python -m venv ./venv \&& . ./venv/bin/activate \&& pip install -r requirements.txt \- && pip install "granian~=2.0"+ && pip install -r requirements-server.txtCOPY ./searx/ ./searx/diff --git a/manage b/manageindex 22f3ae821..cf3abbca6 100755--- a/manage+++ b/manage@@ -126,7 +126,20 @@ webapp.run() {sleep 3xdg-open http://127.0.0.1:8888/)&- SEARXNG_DEBUG=1 pyenv.cmd python -m searx.webapp+ SEARXNG_DEBUG=1 \+ GRANIAN_RELOAD="true" \+ GRANIAN_RELOAD_IGNORE_WORKER_FAILURE="true" \+ GRANIAN_RELOAD_PATHS="./searx" \+ GRANIAN_PROCESS_NAME="searxng" \+ GRANIAN_INTERFACE="wsgi" \+ GRANIAN_HOST="::" \+ GRANIAN_PORT="8888" \+ GRANIAN_WEBSOCKETS="false" \+ GRANIAN_LOOP="uvloop" \+ GRANIAN_BLOCKING_THREADS="4" \+ GRANIAN_WORKERS_KILL_TIMEOUT="30" \+ GRANIAN_BLOCKING_THREADS_IDLE_TIMEOUT="300" \+ pyenv.cmd granian searx.webapp:app}# shellcheck disable=SC2119diff --git a/requirements-dev.txt b/requirements-dev.txtindex f8fd0b754..1fc97d29a 100644--- a/requirements-dev.txt+++ b/requirements-dev.txt@@ -21,3 +21,4 @@ wlc==1.15coloredlogs==15.0.1docutils>=0.21.2parameterized==0.9.0+granian[reload]==2.4.2diff --git a/requirements-server.txt b/requirements-server.txtnew file mode 100644index 000000000..359a3211e--- /dev/null+++ b/requirements-server.txt@@ -0,0 +1 @@+granian==2.4.2diff --git a/searx/webapp.py b/searx/webapp.pyindex 2e1d3dea2..e4253c6e3 100755--- a/searx/webapp.py+++ b/searx/webapp.py@@ -6,7 +6,6 @@# pylint: disable=use-dict-literalfrom __future__ import annotations-import inspectimport jsonimport osimport sys@@ -28,8 +27,6 @@ from pygments import highlightfrom pygments.lexers import get_lexer_by_namefrom pygments.formatters import HtmlFormatter # pylint: disable=no-name-in-module-from werkzeug.serving import is_running_from_reloader-from whitenoise import WhiteNoisefrom whitenoise.base import Headers@@ -1364,38 +1361,6 @@ def run():app.run(port=port, host=host, threaded=True)-def is_werkzeug_reload_active() -> bool:- """Returns ``True`` if server is is launched by :ref:`werkzeug.serving` and- the ``use_reload`` argument was set to ``True``. If this is the case, it- should be avoided that the server is initialized twice (:py:obj:`init`,- :py:obj:`run`).-- .. _werkzeug.serving:- https://werkzeug.palletsprojects.com/en/stable/serving/#werkzeug.serving.run_simple- """- logger.debug("sys.argv: %s", sys.argv)- if "uwsgi" in sys.argv[0] or "granian" in sys.argv[0]:- # server was launched by granian (or uWSGI)- return False-- # https://github.com/searxng/searxng/pull/1656#issuecomment-1214198941- # https://github.com/searxng/searxng/pull/1616#issuecomment-1206137468-- frames = inspect.stack()-- if len(frames) > 1 and frames[-2].filename.endswith('flask/cli.py'):- # server was launched by "flask run", is argument "--reload" set?- if "--reload" in sys.argv or "--debug" in sys.argv:- return True-- elif frames[0].filename.endswith('searx/webapp.py'):- # server was launched by "python -m searx.webapp" / see run()- if searx.sxng_debug:- return True-- return False--def init():if searx.sxng_debug or app.debug:@@ -1408,17 +1373,6 @@ def init():logger.error("server.secret_key is not changed. Please use something else instead of ultrasecretkey.")sys.exit(1)- # When automatic reloading is activated stop Flask from initialising twice.- # - https://github.com/pallets/flask/issues/5307#issuecomment-1774646119- # - https://stackoverflow.com/a/25504196-- reloader_active = is_werkzeug_reload_active()- werkzeug_run_main = is_running_from_reloader()-- if reloader_active and not werkzeug_run_main:- logger.info("in reloading mode and not in main loop, cancel the initialization")- return-locales_initialize()valkey_initialize()searx.plugins.initialize(app)