def stop(self, name='lyrebird'): try: os.kill(config.Config(name=name).read_pid(), SIGTERM) except Exception: # 未找到进程时不处理 pass config.Config(name=name).remove_pid()
def init_conf(self): self._conf_manager = config.Config(name=self.pid_file_name) self._conf_manager.init() self._conf_manager.save_pid() custom_args = {} if self._mock_port: custom_args['mock.port'] = self._mock_port if self._proxy_port: custom_args['proxy.port'] = self._proxy_port if self._data_root_dir: custom_args['mock.data'] = self._data_root_dir cache = self._conf_manager.load_cache() if self.custom_conf_name == None: self.custom_conf_name = cache.get('custom_conf') else: cache['custom_conf'] = self.custom_conf_name self._conf_manager.save_cache(cache) if cache.get('user_data_uri'): self._conf_manager.download(cache.get('user_data_uri')) self._conf = self._conf_manager.load_tmp(self.custom_conf_name, **custom_args) self._conf['ip'] = get_ip()
def set_cache_uri(self, uri): self._conf_manager = config.Config(name=self.pid_file_name) self._conf_manager.init() cache = self._conf_manager.load_cache() cache['user_data_uri'] = uri self._conf_manager.save_cache(cache)