mirror of
https://github.com/norohind/jubilant-system-core.git
synced 2025-07-18 01:01:38 +03:00
Compare commits
No commits in common. "5027ef748c55007813c4c1eb75b9c030b6f543ad" and "8cd624aed3611d29cecc43a331bb0c2ce059d87b" have entirely different histories.
5027ef748c
...
8cd624aed3
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import functools
|
||||
import threading
|
||||
from Hook import Hook
|
||||
import importlib.machinery
|
||||
import HookUtils
|
||||
@ -93,7 +94,7 @@ class HookSystem:
|
||||
|
||||
threading.Thread(
|
||||
name=f'bootstrap-hook-thread-{operation_id}',
|
||||
target=lambda: HookSystem._call_hooks(operation_id, hooks, get_latest()),
|
||||
target=lambda: HookSystem._call_hooks(operation_id, hooks, copy.deepcopy(get_latest())),
|
||||
).start()
|
||||
|
||||
@staticmethod
|
||||
@ -102,5 +103,5 @@ class HookSystem:
|
||||
threading.Thread(
|
||||
name=f'hook-{hook.__class__.__name__}-{operation_id}',
|
||||
target=hook.update,
|
||||
args=(operation_id, copy.deepcopy(latest_records))
|
||||
args=(operation_id, latest_records)
|
||||
).start()
|
||||
|
33
main.py
33
main.py
@ -57,11 +57,6 @@ def shutdown_callback(sig: int, frame) -> None:
|
||||
exit(0)
|
||||
|
||||
|
||||
def threads_dump(sig: int, frame) -> None:
|
||||
running_threads = ', '.join((thread.name for thread in threading.enumerate()))
|
||||
logger.info(f'Running threads: {running_threads}')
|
||||
|
||||
|
||||
def discover(back_count: int = 0):
|
||||
"""Discover new squads
|
||||
:param back_count: int how many squads back we should check, it is helpful to recheck newly created squads
|
||||
@ -158,11 +153,6 @@ def main():
|
||||
global can_be_shutdown
|
||||
signal.signal(signal.SIGTERM, shutdown_callback)
|
||||
signal.signal(signal.SIGINT, shutdown_callback)
|
||||
try:
|
||||
signal.signal(signal.SIGUSR1, threads_dump)
|
||||
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def help_cli() -> str:
|
||||
return """Possible arguments:
|
||||
@ -170,8 +160,7 @@ def main():
|
||||
main.py update
|
||||
main.py update amount <amount: int>
|
||||
main.py update id <id: int>
|
||||
main.py daemon
|
||||
main.py hooks notify <inserted;deleted> <operation_id: int>"""
|
||||
main.py daemon"""
|
||||
|
||||
logger.debug(f'argv: {sys.argv}')
|
||||
|
||||
@ -254,26 +243,6 @@ def main():
|
||||
else:
|
||||
logger.info(f'Unknown argument {sys.argv[2]}')
|
||||
|
||||
elif len(sys.argv) == 5:
|
||||
# main.py hooks notify <inserted;deleted> <operation_id: int>
|
||||
if sys.argv[1] == 'hooks' and sys.argv[2] == 'notify' and sys.argv[3] in ('inserted', 'deleted'):
|
||||
try:
|
||||
operation_id = int(sys.argv[4])
|
||||
|
||||
except ValueError:
|
||||
operation_id = 0
|
||||
print('operation_id must be integer')
|
||||
exit(1)
|
||||
|
||||
logger.info(f'Notifying {sys.argv[3]} hooks with {operation_id=}')
|
||||
|
||||
if sys.argv[3] == 'inserted':
|
||||
FAPI.hook_system.notify_inserted(operation_id)
|
||||
|
||||
else: # deleted
|
||||
FAPI.hook_system.notify_deleted(operation_id)
|
||||
|
||||
exit(0)
|
||||
else:
|
||||
print(help_cli())
|
||||
exit(1)
|
||||
|
@ -312,5 +312,3 @@ begin
|
||||
news_id = new.news_id,
|
||||
"date" = new.date;
|
||||
end;
|
||||
|
||||
create index if not exists idx_snh_operation_id_desc on squadrons_news_historical (operation_id desc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user