don't run relay via dev script in dev mode by default

This commit is contained in:
Izalia Mae 2024-03-15 21:17:20 -04:00
parent f488d661d7
commit 94f4d32314

View file

@ -86,10 +86,11 @@ def cli_build():
@cli.command('run') @cli.command('run')
def cli_run(): @click.option('--dev', '-d', is_flag = True)
def cli_run(dev: bool):
print('Starting process watcher') print('Starting process watcher')
handler = WatchHandler() handler = WatchHandler(dev)
handler.run_proc() handler.run_proc()
watcher = Observer() watcher = Observer()
@ -112,12 +113,13 @@ def cli_run():
class WatchHandler(PatternMatchingEventHandler): class WatchHandler(PatternMatchingEventHandler):
patterns = ['*.py'] patterns = ['*.py']
cmd = [sys.executable, '-m', 'relay', 'run', '-d'] cmd = [sys.executable, '-m', 'relay', 'run']
def __init__(self): def __init__(self, dev: bool):
PatternMatchingEventHandler.__init__(self) PatternMatchingEventHandler.__init__(self)
self.dev: bool = dev
self.proc = None self.proc = None
self.last_restart = None self.last_restart = None
@ -152,7 +154,12 @@ class WatchHandler(PatternMatchingEventHandler):
self.kill_proc() 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) self.proc = subprocess.Popen(self.cmd, stdin = subprocess.PIPE)
self.last_restart = timestamp self.last_restart = timestamp
print(f'Started process with PID {self.proc.pid}') print(f'Started process with PID {self.proc.pid}')