Browse Source

!989 update mindinsight settings in stop script

From: @liangyongxiong1024
Reviewed-by: @wenkai_dist,@lilongfei15
Signed-off-by: @lilongfei15
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
2f116ab232
2 changed files with 7 additions and 14 deletions
  1. +0
    -10
      mindinsight/conf/__init__.py
  2. +7
    -4
      mindinsight/scripts/stop.py

+ 0
- 10
mindinsight/conf/__init__.py View File

@@ -110,16 +110,6 @@ class Settings:
setattr(self, setting, value) setattr(self, setting, value)
self._explicit_settings.add(setting) 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): def is_overridden(self, setting_name):
""" """
Check if specified setting is overridden. Check if specified setting is overridden.


+ 7
- 4
mindinsight/scripts/stop.py View File

@@ -56,7 +56,6 @@ class Command(BaseCommand):
description = 'stop mindinsight service' description = 'stop mindinsight service'


cmd_regex = 'mindinsight.backend.application:APP' cmd_regex = 'mindinsight.backend.application:APP'
access_log_path = os.path.join('gunicorn', 'access.{}.log'.format(settings.PORT))


def add_arguments(self, parser): def add_arguments(self, parser):
""" """
@@ -84,9 +83,12 @@ class Command(BaseCommand):
args.port = settings.PORT args.port = settings.PORT


pid, workspace = self.get_process(args.port) pid, workspace = self.get_process(args.port)
settings.config_workspace(workspace)
setattr(args, 'pid', pid) setattr(args, 'pid', pid)


os.environ['MINDINSIGHT_PORT'] = str(args.port)
os.environ['MINDINSIGHT_WORKSPACE'] = workspace
settings.refresh()

def run(self, args): def run(self, args):
""" """
Run to stop. Run to stop.
@@ -164,9 +166,10 @@ class Command(BaseCommand):


pid = gunicorn_master_process.pid pid = gunicorn_master_process.pid


access_log_path = os.path.join('gunicorn', 'access.{}.log'.format(port))
for open_file in process.open_files(): 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)) workspace = os.path.realpath(os.path.join(log_base_dir, os.pardir))
break break
break break


Loading…
Cancel
Save