mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-10-27 07:14:08 +09:00
cli.py runs as a plain python script, so the factory's flask-argv sniff never matched it: every serverkit verb booted a second job consumer, scheduler and relay beside the live panel, whose boot reconcile marks the panel's in-flight deploys failed.
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""`serverkit <verb>` must not boot a second set of background daemons.
|
|
|
|
The CLI runs as `python cli.py ...`, so the app factory's `flask`-argv sniff
|
|
never matched it: every command started a job consumer, scheduler and relay
|
|
beside the live panel. Importing cli.py now opts the process out.
|
|
"""
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
BACKEND = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
PROBE = ("import os, cli; "
|
|
"print(os.environ.get('SERVERKIT_SKIP_BACKGROUND'))")
|
|
|
|
|
|
def _probe(**env):
|
|
child_env = {k: v for k, v in os.environ.items()
|
|
if k != 'SERVERKIT_SKIP_BACKGROUND'}
|
|
child_env.update(env)
|
|
out = subprocess.run([sys.executable, '-c', PROBE], cwd=BACKEND,
|
|
env=child_env, capture_output=True, text=True,
|
|
timeout=120)
|
|
assert out.returncode == 0, out.stderr
|
|
return out.stdout.strip().splitlines()[-1]
|
|
|
|
|
|
def test_cli_import_skips_background_daemons():
|
|
assert _probe() == '1'
|
|
|
|
|
|
def test_explicit_operator_setting_wins():
|
|
assert _probe(SERVERKIT_SKIP_BACKGROUND='0') == '0'
|