Improved live dev server

This commit is contained in:
Sven Heidemann 2021-03-13 11:15:15 +01:00
parent dcbd13de1e
commit 787d285329
2 changed files with 9 additions and 8 deletions

View File

@ -23,7 +23,7 @@ class LiveServerService(ServiceABC, FileSystemEventHandler):
self._build_settings = build_settings
self._src_dir = os.path.join(self._runtime.working_directory, self._build_settings.source_path)
self._live_server = LiveServerThread(self._src_dir)
self._ls_thread = LiveServerThread(self._src_dir)
self._observer = None
def _start_observer(self):
@ -34,15 +34,15 @@ class LiveServerService(ServiceABC, FileSystemEventHandler):
def _restart(self):
for proc in psutil.process_iter():
with suppress(Exception):
if proc.cmdline() == self._live_server.command:
os.system(f'pkill -f {self._live_server.main}')
if proc.cmdline() == self._ls_thread.command:
os.system(f'pkill -f {self._ls_thread.main}')
Console.write_line('Restart\n')
while self._live_server.is_alive():
while self._ls_thread.is_alive():
time.sleep(1)
self._live_server = LiveServerThread(self._src_dir)
self._live_server.start()
self._ls_thread = LiveServerThread(self._src_dir)
self._ls_thread.start()
self._start_observer()
@ -58,7 +58,7 @@ class LiveServerService(ServiceABC, FileSystemEventHandler):
def start(self):
Console.write_line('** CPL live development server is running **')
self._start_observer()
self._live_server.start()
self._ls_thread.start()
Console.close()
Console.write('\n')

View File

@ -2,6 +2,7 @@ import time
from typing import Optional
from cpl.application.application_abc import ApplicationABC
from cpl.console import ForegroundColorEnum
from cpl.console.console import Console
from cpl.logging.logger_abc import LoggerABC
from cpl.mailing.email import EMail
@ -47,6 +48,6 @@ class Application(ApplicationABC):
self._logger.debug(__name__, f'Host: {self._configuration.environment.host_name}')
self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}')
self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}')
Console.spinner('Test', self._wait, 999999, spinner_foreground_color='red')
Console.spinner('Test', self._wait, 20, spinner_foreground_color='red')
# self.test_send_mail()
# self.test_console()