From 9d80abadd87075b1d6b2d6b2726aecde4cf64d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Fri, 9 Dec 2022 16:35:29 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/commands/services/services/base.py | 11 ++++++----- apps/common/management/commands/services/utils.py | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/common/management/commands/services/services/base.py b/apps/common/management/commands/services/services/base.py index 870014474..ddcb4feca 100644 --- a/apps/common/management/commands/services/services/base.py +++ b/apps/common/management/commands/services/services/base.py @@ -44,9 +44,12 @@ class BaseService(object): if self.is_running: msg = f'{self.name} is running: {self.pid}.' else: - msg = '\033[31m{} is stopped.\033[0m\nYou can manual start it to find the error: \n' \ - ' $ cd {}\n' \ - ' $ {}'.format(self.name, self.cwd, ' '.join(self.cmd)) + msg = f'{self.name} is stopped.' + if DEBUG: + msg = '\033[31m{} is stopped.\033[0m\nYou can manual start it to find the error: \n' \ + ' $ cd {}\n' \ + ' $ {}'.format(self.name, self.cwd, ' '.join(self.cmd)) + print(msg) # -- log -- @@ -147,7 +150,6 @@ class BaseService(object): self.remove_pid() break else: - time.sleep(1) continue def watch(self): @@ -203,4 +205,3 @@ class BaseService(object): logging.info(f'Remove old log: {to_delete_dir}') shutil.rmtree(to_delete_dir, ignore_errors=True) # -- end action -- - diff --git a/apps/common/management/commands/services/utils.py b/apps/common/management/commands/services/utils.py index afa642a1a..7ad6ea7f9 100644 --- a/apps/common/management/commands/services/utils.py +++ b/apps/common/management/commands/services/utils.py @@ -40,7 +40,8 @@ class ServicesUtil(object): service: BaseService service.start() self.files_preserve_map[service.name] = service.log_file - time.sleep(1) + + time.sleep(1) def stop(self): for service in self._services: