diff options
author | Alexandre Flament <alex@al-f.net> | 2021-01-05 11:24:39 +0100 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-01-12 11:47:17 +0100 |
commit | 3a9f513521d006a7939538cce368d7b799e32c30 (patch) | |
tree | 238da19ef56643af53b13ef24a330277ed53ae51 /searx/webapp.py | |
parent | 6e2872f43625aba71eba019e16f7fbd74743f590 (diff) | |
download | searxng-3a9f513521d006a7939538cce368d7b799e32c30.tar.gz searxng-3a9f513521d006a7939538cce368d7b799e32c30.zip |
[enh] checker: background check
See settings.yml for the options
SIGUSR1 signal starts the checker.
The result is available at /stats/checker
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-x | searx/webapp.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 10f4ce78c..985eced18 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -71,7 +71,8 @@ from searx.webadapter import get_search_query_from_webapp, get_selected_categori from searx.utils import html_to_text, gen_useragent, dict_subset, match_language from searx.version import VERSION_STRING from searx.languages import language_codes as languages -from searx.search import SearchWithPlugins, initialize +from searx.search import SearchWithPlugins, initialize as search_initialize +from searx.search.checker import get_result as checker_get_result from searx.query import RawTextQuery from searx.autocomplete import searx_bang, backends as autocomplete_backends from searx.plugins import plugins @@ -81,7 +82,6 @@ from searx.answerers import answerers from searx.poolrequests import get_global_proxies from searx.metrology.error_recorder import errors_per_engines - # serve pages with HTTP/1.1 from werkzeug.serving import WSGIRequestHandler WSGIRequestHandler.protocol_version = "HTTP/{}".format(settings['server'].get('http_protocol_version', '1.0')) @@ -136,7 +136,7 @@ werkzeug_reloader = flask_run_development or (searx_debug and __name__ == "__mai # initialize the engines except on the first run of the werkzeug server. if not werkzeug_reloader\ or (werkzeug_reloader and os.environ.get("WERKZEUG_RUN_MAIN") == "true"): - initialize() + search_initialize(enable_checker=True) babel = Babel(app) @@ -977,6 +977,12 @@ def stats_errors(): return jsonify(result) +@app.route('/stats/checker', methods=['GET']) +def stats_checker(): + result = checker_get_result() + return jsonify(result) + + @app.route('/robots.txt', methods=['GET']) def robots(): return Response("""User-agent: * |