From 786936fb8895debde9f19e3742bf93bc4807573c Mon Sep 17 00:00:00 2001 From: liangyongxiong Date: Tue, 8 Dec 2020 14:11:05 +0800 Subject: [PATCH] update mindinsight settings in stop script --- mindinsight/conf/__init__.py | 10 ---------- mindinsight/scripts/stop.py | 11 +++++++---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/mindinsight/conf/__init__.py b/mindinsight/conf/__init__.py index c395388c..e694c033 100644 --- a/mindinsight/conf/__init__.py +++ b/mindinsight/conf/__init__.py @@ -110,16 +110,6 @@ class Settings: setattr(self, setting, value) self._explicit_settings.add(setting) - def config_workspace(self, workspace): - """ - Config workspace value. - - Args: - workspace (str): Path of workspace. - """ - setattr(self, 'WORKSPACE', workspace) - self._explicit_settings.add('WORKSPACE') - def is_overridden(self, setting_name): """ Check if specified setting is overridden. diff --git a/mindinsight/scripts/stop.py b/mindinsight/scripts/stop.py index 2e4ee34e..55562ca9 100644 --- a/mindinsight/scripts/stop.py +++ b/mindinsight/scripts/stop.py @@ -56,7 +56,6 @@ class Command(BaseCommand): description = 'stop mindinsight service' cmd_regex = 'mindinsight.backend.application:APP' - access_log_path = os.path.join('gunicorn', 'access.{}.log'.format(settings.PORT)) def add_arguments(self, parser): """ @@ -84,9 +83,12 @@ class Command(BaseCommand): args.port = settings.PORT pid, workspace = self.get_process(args.port) - settings.config_workspace(workspace) setattr(args, 'pid', pid) + os.environ['MINDINSIGHT_PORT'] = str(args.port) + os.environ['MINDINSIGHT_WORKSPACE'] = workspace + settings.refresh() + def run(self, args): """ Run to stop. @@ -164,9 +166,10 @@ class Command(BaseCommand): pid = gunicorn_master_process.pid + access_log_path = os.path.join('gunicorn', 'access.{}.log'.format(port)) for open_file in process.open_files(): - if open_file.path.endswith(self.access_log_path): - log_base_dir = open_file.path[:-len(self.access_log_path)] + if open_file.path.endswith(access_log_path): + log_base_dir = open_file.path[:-len(access_log_path)] workspace = os.path.realpath(os.path.join(log_base_dir, os.pardir)) break break