From c961fadc9ae4bbe4cc20cca78685093e2fddf239 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Fri, 15 Mar 2024 21:23:57 -0400 Subject: [PATCH] don't run relay via dev script in dev mode by default --- relay/dev.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/relay/dev.py b/relay/dev.py index 52eeadc..f145d24 100644 --- a/relay/dev.py +++ b/relay/dev.py @@ -9,6 +9,7 @@ from pathlib import Path from tempfile import TemporaryDirectory from . import __version__ +from . import logger as logging try: from watchdog.observers import Observer @@ -128,7 +129,7 @@ class WatchHandler(PatternMatchingEventHandler): if self.proc.poll() is not None: return - print(f'Terminating process {self.proc.pid}') + logging.info(f'Terminating process {self.proc.pid}') self.proc.terminate() sec = 0.0 @@ -137,11 +138,11 @@ class WatchHandler(PatternMatchingEventHandler): sec += 0.1 if sec >= 5: - print('Failed to terminate. Killing process...') + logging.error('Failed to terminate. Killing process...') self.proc.kill() break - print('Process terminated') + logging.info('Process terminated') def run_proc(self, restart=False): @@ -154,15 +155,13 @@ class WatchHandler(PatternMatchingEventHandler): self.kill_proc() - if self.dev: - self.proc = subprocess.Popen([*self.cmd, '-d'], stdin = subprocess.PIPE) - - else: - self.proc = subprocess.Popen(self.cmd, stdin = subprocess.PIPE) + cmd = [*self.cmd, '-d'] if self.dev else self.cmd + self.proc = subprocess.Popen(cmd, stdin = subprocess.PIPE) self.last_restart = timestamp - print(f'Started process with PID {self.proc.pid}') + logging.info('Started process with PID %i', self.proc.pid) + logging.info('Command: %s', ' '.join(cmd)) def on_any_event(self, event):