perf: 优化启动速度

pull/9215/head
吴小白 2022-12-09 16:35:29 +08:00 committed by Jiangjie.Bai
parent 11a58dc7ad
commit 9d80abadd8
2 changed files with 8 additions and 6 deletions

View File

@ -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 --

View File

@ -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: