Refactor store dwell alert management API and dwell engine

- Updated argument parsing in manage_api.py to include new threshold parameters.
- Enhanced _config_payload to include thresholds and webhook configurations.
- Modified _build_summary to track queue metrics and adjust alert reporting.
- Refactored DwellEngine to utilize queue thresholds for alerting and reporting.
- Added queue metrics calculations and status change tracking in dwell_engine.py.
- Updated notifier.py to support posting JSON events to webhooks.
- Adjusted example configuration to reflect new threshold parameters.
- Enhanced Docker entrypoint script for better process management.
- Updated tests to cover new queue metrics and thresholds.
- Improved ManagedServiceDetail and ManagedServices Vue components to display queue metrics.
This commit is contained in:
2026-05-09 11:35:55 +08:00
parent be5014c582
commit ea618fd674
26 changed files with 1605 additions and 117 deletions

View File

@@ -40,4 +40,67 @@ config_path.write_text(
)
PY
exec python -m app.manage_api --config "${CONFIG_PATH}" --host "${API_HOST}" --port "${API_PORT}"
exec python - "$CONFIG_PATH" "$API_HOST" "$API_PORT" <<'PY'
import signal
import subprocess
import sys
import time
config_path, api_host, api_port = sys.argv[1:4]
commands = [
[sys.executable, "-m", "app.main", "--config", config_path],
[
sys.executable,
"-m",
"app.manage_api",
"--config",
config_path,
"--host",
api_host,
"--port",
api_port,
],
]
processes = [subprocess.Popen(command) for command in commands]
def terminate_all(signum, _frame):
for process in processes:
if process.poll() is None:
process.terminate()
deadline = time.time() + 10
for process in processes:
if process.poll() is not None:
continue
timeout = max(0, deadline - time.time())
try:
process.wait(timeout=timeout)
except subprocess.TimeoutExpired:
process.kill()
raise SystemExit(128 + signum)
for handled_signal in (signal.SIGINT, signal.SIGTERM):
signal.signal(handled_signal, terminate_all)
while True:
for index, process in enumerate(processes):
return_code = process.poll()
if return_code is None:
continue
for other_index, other_process in enumerate(processes):
if other_index == index or other_process.poll() is not None:
continue
other_process.terminate()
deadline = time.time() + 10
for other_index, other_process in enumerate(processes):
if other_index == index or other_process.poll() is not None:
continue
timeout = max(0, deadline - time.time())
try:
other_process.wait(timeout=timeout)
except subprocess.TimeoutExpired:
other_process.kill()
raise SystemExit(return_code)
time.sleep(0.5)
PY