diff options
| author | Alexandre Flament <alex@al-f.net> | 2020-10-05 11:20:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-05 11:20:46 +0200 |
| commit | 584760cf5419051bd3f37e733147e048356f7ffc (patch) | |
| tree | 54990d1a734034f37a0c265de913095cb788efab /searx/webapp.py | |
| parent | b728cb610b92161609b1c40babff25749720fc25 (diff) | |
| parent | 6c39917c4d3e3d3d6ced3fc14d1c78842fec3a19 (diff) | |
Merge pull request #2237 from dalf/mod-engines-init
Mod engines init
Diffstat (limited to 'searx/webapp.py')
| -rwxr-xr-x | searx/webapp.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 5723734c1..c19d3f3cc 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -65,7 +65,7 @@ from searx.engines import ( from searx.webutils import ( UnicodeWriter, highlight_content, get_resources_directory, get_static_files, get_result_templates, get_themes, - prettify_url, new_hmac + prettify_url, new_hmac, is_flask_run_cmdline ) from searx.webadapter import get_search_query_from_webapp, get_selected_categories from searx.utils import html_to_text, gen_useragent, dict_subset, match_language @@ -114,9 +114,21 @@ app.jinja_env.lstrip_blocks = True app.jinja_env.add_extension('jinja2.ext.loopcontrols') app.secret_key = settings['server']['secret_key'] -if not searx_debug \ - or os.environ.get("WERKZEUG_RUN_MAIN") == "true" \ - or os.environ.get('UWSGI_ORIGINAL_PROC_NAME') is not None: +# see https://flask.palletsprojects.com/en/1.1.x/cli/ +# True if "FLASK_APP=searx/webapp.py FLASK_ENV=development flask run" +flask_run_development = \ + os.environ.get("FLASK_APP") is not None\ + and os.environ.get("FLASK_ENV") == 'development'\ + and is_flask_run_cmdline() + +# True if reload feature is activated of werkzeug, False otherwise (including uwsgi, etc..) +# __name__ != "__main__" if searx.webapp is imported (make test, make docs, uwsgi...) +# see run() at the end of this file : searx_debug activates the reload feature. +werkzeug_reloader = flask_run_development or (searx_debug and __name__ == "__main__") + +# 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_engines(settings['engines']) babel = Babel(app) |