diff --git a/nix/checks/proxy-inbounds-runtime.nix b/nix/checks/proxy-inbounds-runtime.nix index 5c67ed9..df34f53 100644 --- a/nix/checks/proxy-inbounds-runtime.nix +++ b/nix/checks/proxy-inbounds-runtime.nix @@ -168,7 +168,9 @@ pkgs.testers.runNixOSTest { with subtest("runtime users and listeners"): cfg = "/run/proxy-suite-inbounds/config.json" server.succeed("proxy-ctl inbounds users add friend --listener vless-in") - server.succeed(f"jq -e '.inbounds[] | select(.tag == \"vless-in\") | .settings.clients | map(.email) == [\"tester\", \"friend\"]' {cfg}") + # The reload's restart returns once the start script is forked: config.json is + # gone until it renders it again. + server.wait_until_succeeds(f"jq -e '.inbounds[] | select(.tag == \"vless-in\") | .settings.clients | map(.email) == [\"tester\", \"friend\"]' {cfg}") server.succeed("proxy-ctl inbounds add rt vless --port 9001 --user friend --user tester") server.wait_for_open_port(9001) server.succeed("proxy-ctl inbounds users | grep friend | grep -q rt") @@ -196,6 +198,6 @@ pkgs.testers.runNixOSTest { server.succeed("journalctl -u proxy-suite-inbounds | grep -q \"ignoring runtime listener 'rt'\"") server.succeed("rm /var/lib/proxy-suite/inbounds.d/listeners/rt.json") server.succeed("proxy-ctl inbounds users rm friend") - server.succeed(f"jq -e '.inbounds[] | select(.tag == \"vless-in\") | .settings.clients | map(.email) == [\"tester\"]' {cfg}") + server.wait_until_succeeds(f"jq -e '.inbounds[] | select(.tag == \"vless-in\") | .settings.clients | map(.email) == [\"tester\"]' {cfg}") ''; } diff --git a/pkgs/proxy-ctl/proxy_ctl.py b/pkgs/proxy-ctl/proxy_ctl.py index b65e7d8..4304b98 100644 --- a/pkgs/proxy-ctl/proxy_ctl.py +++ b/pkgs/proxy-ctl/proxy_ctl.py @@ -2499,14 +2499,23 @@ def _subscription_cache(tag): def _runtime_entry_verify(kind, tag): - """Only the backend parses the entry, so confirm it actually came up.""" - if kind == "outbound": - if tag in _outbound_tags(): - print(f"Added outbound: {tag}") + """Only the backend parses the entry, so confirm it actually came up. + + The reload's restart returns once the start script is forked, before it writes the + inventory again, so this gives it a moment. + """ + deadline = time.monotonic() + 15 + while True: + if kind == "outbound": + if tag in _outbound_tags(): + print(f"Added outbound: {tag}") + return + elif os.path.isfile(_subscription_cache(tag)): + print(f"Added subscription: {tag} ({_subscription_proxy_count_text(_subscription_cache(tag))} proxies)") return - elif os.path.isfile(_subscription_cache(tag)): - print(f"Added subscription: {tag} ({_subscription_proxy_count_text(_subscription_cache(tag))} proxies)") - return + if time.monotonic() >= deadline: + break + time.sleep(0.5) sys.stdout.flush() print(f"Saved {kind} '{tag}', but it did not come up. Check: proxy-ctl logs", file=sys.stderr) print(f"Remove it again with: proxy-ctl proxy {_runtime_noun(kind)} rm {tag}", file=sys.stderr)