Skip to content

Commit 64325d8

Browse files
committed
fetch_web: configurable delay
1 parent 8367baf commit 64325d8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pyplugins/actuation/fetch_web.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ def __init__(self, panda):
2323
self.outdir = self.get_arg("outdir")
2424
self.shutdown_after_www = self.get_arg_bool("shutdown_after_www")
2525
self.shutdown_on_failure = self.get_arg_bool("shutdown_on_failure")
26+
self.logger = getColoredLogger("plugins.fetch_web")
27+
if (delay := self.get_arg("fetch_delay")):
28+
self.fetch_delay = int(delay)
29+
self.logger.info(f"Fetch delay set to {self.fetch_delay} seconds")
30+
else:
31+
self.fetch_delay = 20
2632
self.task_queue = queue.Queue()
2733
plugins.subscribe(plugins.VPN, "on_bind", self.fetchweb_on_bind)
28-
self.logger = getColoredLogger("plugins.fetch_web")
2934
self.shutting_down = False
3035

3136
self.worker_thread = threading.Thread(target=self.worker)
@@ -77,7 +82,7 @@ def fetch(self, guest_ip, host_ip, guest_port, host_port, log_file_name):
7782
if os.path.isfile(log_file_name):
7883
log_file_name += ".alt"
7984

80-
time.sleep(20) # Give service plenty of time to start
85+
time.sleep(self.fetch_delay) # Give service plenty of time to start
8186
cmd = ["wget", "-q", f"https://{host_ip}:{host_port}" if guest_port == 443 else f"http://{host_ip}:{host_port}",
8287
"--no-check-certificate", "-O", log_file_name]
8388
timestamp = f"{(time.time() - self.start_time):.02f}s"

0 commit comments

Comments
 (0)