mirror of
https://github.com/searxng/searxng
synced 2024-11-18 15:26:25 +00:00
[fix] checker: don't run the checker when uwsgi is not properly configured
Before this commit, even with the scheduler disabled, the checker was running at least once for each uwsgi worker.
This commit is contained in:
parent
7f0c508598
commit
912c7e975c
@ -40,8 +40,9 @@ def get_result():
|
|||||||
return json.loads(serialized_result)
|
return json.loads(serialized_result)
|
||||||
|
|
||||||
|
|
||||||
def _set_result(result):
|
def _set_result(result, include_timestamp=True):
|
||||||
result['timestamp'] = int(time.time() / 3600) * 3600
|
if include_timestamp:
|
||||||
|
result['timestamp'] = int(time.time() / 3600) * 3600
|
||||||
storage.set_str(CHECKER_RESULT, json.dumps(result))
|
storage.set_str(CHECKER_RESULT, json.dumps(result))
|
||||||
|
|
||||||
|
|
||||||
@ -82,8 +83,8 @@ def _run_with_delay():
|
|||||||
|
|
||||||
def _start_scheduling():
|
def _start_scheduling():
|
||||||
every = _get_every()
|
every = _get_every()
|
||||||
schedule(every[0], _run_with_delay)
|
if schedule(every[0], _run_with_delay):
|
||||||
run()
|
run()
|
||||||
|
|
||||||
|
|
||||||
def _signal_handler(signum, frame):
|
def _signal_handler(signum, frame):
|
||||||
@ -111,7 +112,7 @@ def initialize():
|
|||||||
return
|
return
|
||||||
|
|
||||||
#
|
#
|
||||||
_set_result({'status': 'unknown'})
|
_set_result({'status': 'unknown'}, include_timestamp=False)
|
||||||
|
|
||||||
start_after = scheduling.get('start_after', (300, 1800))
|
start_after = scheduling.get('start_after', (300, 1800))
|
||||||
start_after = _get_interval(start_after, 'checker.scheduling.start_after is not a int or list')
|
start_after = _get_interval(start_after, 'checker.scheduling.start_after is not a int or list')
|
||||||
|
@ -22,7 +22,7 @@ else:
|
|||||||
from .shared_simple import SimpleSharedDict as SharedDict
|
from .shared_simple import SimpleSharedDict as SharedDict
|
||||||
|
|
||||||
def schedule(delay, func, *args):
|
def schedule(delay, func, *args):
|
||||||
pass
|
return False
|
||||||
else:
|
else:
|
||||||
# uwsgi
|
# uwsgi
|
||||||
from .shared_uwsgi import UwsgiCacheSharedDict as SharedDict, schedule
|
from .shared_uwsgi import UwsgiCacheSharedDict as SharedDict, schedule
|
||||||
|
@ -36,3 +36,4 @@ def schedule(delay, func, *args):
|
|||||||
func(*args)
|
func(*args)
|
||||||
|
|
||||||
call_later()
|
call_later()
|
||||||
|
return True
|
||||||
|
@ -61,3 +61,4 @@ def schedule(delay, func, *args):
|
|||||||
_last_signal += 1
|
_last_signal += 1
|
||||||
uwsgi.register_signal(signal_num, 'worker', sighandler)
|
uwsgi.register_signal(signal_num, 'worker', sighandler)
|
||||||
uwsgi.add_timer(signal_num, delay)
|
uwsgi.add_timer(signal_num, delay)
|
||||||
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user