Lines Matching refs:self

44     def __init__(self, env: Env, port: int, https_port: int, name: str):  argument
45 self.env = env
46 self._name = name
47 self._port = port
48 self._https_port = https_port
49 self._cmd = env.nghttpx
50 self._run_dir = os.path.join(env.gen_dir, name)
51 self._pid_file = os.path.join(self._run_dir, 'nghttpx.pid')
52 self._conf_file = os.path.join(self._run_dir, 'nghttpx.conf')
53 self._error_log = os.path.join(self._run_dir, 'nghttpx.log')
54 self._stderr = os.path.join(self._run_dir, 'nghttpx.stderr')
55 self._tmp_dir = os.path.join(self._run_dir, 'tmp')
56 self._process: Optional[subprocess.Popen] = None
57 self._rmf(self._pid_file)
58 self._rmf(self._error_log)
59 self._mkpath(self._run_dir)
60 self._write_config()
63 def https_port(self): argument
64 return self._https_port
66 def exists(self): argument
67 return self._cmd and os.path.exists(self._cmd)
69 def clear_logs(self): argument
70 self._rmf(self._error_log)
71 self._rmf(self._stderr)
73 def is_running(self): argument
74 if self._process:
75 self._process.poll()
76 return self._process.returncode is None
79 def start_if_needed(self): argument
80 if not self.is_running():
81 return self.start()
84 def start(self, wait_live=True): argument
87 def stop_if_running(self): argument
88 if self.is_running():
89 return self.stop()
92 def stop(self, wait_dead=True): argument
93 self._mkpath(self._tmp_dir)
94 if self._process:
95 self._process.terminate()
96 self._process.wait(timeout=2)
97 self._process = None
98 return not wait_dead or self.wait_dead(timeout=timedelta(seconds=5))
101 def restart(self): argument
102 self.stop()
103 return self.start()
105 def reload(self, timeout: timedelta): argument
106 if self._process:
107 running = self._process
108 self._process = None
111 if not self.start(wait_live=False):
112 self._process = running
128 return self.wait_live(timeout=timedelta(seconds=5))
131 def wait_dead(self, timeout: timedelta): argument
132 curl = CurlClient(env=self.env, run_dir=self._tmp_dir)
135 if self._https_port > 0:
154 def wait_live(self, timeout: timedelta): argument
155 curl = CurlClient(env=self.env, run_dir=self._tmp_dir)
158 if self._https_port > 0:
177 def _rmf(self, path): argument
181 def _mkpath(self, path): argument
185 def _write_config(self): argument
186 with open(self._conf_file, 'w') as fd:
195 def __init__(self, env: Env): argument
199 def start(self, wait_live=True): argument
200 self._mkpath(self._tmp_dir)
201 if self._process:
202 self.stop()
203 creds = self.env.get_credentials(self.env.domain1)
206 self._cmd,
224 ngerr = open(self._stderr, 'a')
225 self._process = subprocess.Popen(args=args, stderr=ngerr)
226 if self._process.returncode is not None:
228 return not wait_live or self.wait_live(timeout=timedelta(seconds=5))
233 def __init__(self, env: Env): argument
237 def start(self, wait_live=True): argument
238 self._mkpath(self._tmp_dir)
239 if self._process:
240 self.stop()
241 creds = self.env.get_credentials(self.env.proxy_domain)
244 self._cmd,
256 ngerr = open(self._stderr, 'a')
257 self._process = subprocess.Popen(args=args, stderr=ngerr)
258 if self._process.returncode is not None:
260 return not wait_live or self.wait_live(timeout=timedelta(seconds=5))
262 def wait_dead(self, timeout: timedelta): argument
263 curl = CurlClient(env=self.env, run_dir=self._tmp_dir)
275 def wait_live(self, timeout: timedelta): argument
276 curl = CurlClient(env=self.env, run_dir=self._tmp_dir)