Lines Matching refs:self

43     def __init__(self, env: Env):  argument
44 self.env = env
45 self._caddy = os.environ['CADDY'] if 'CADDY' in os.environ else env.caddy
46 self._caddy_dir = os.path.join(env.gen_dir, 'caddy')
47 self._docs_dir = os.path.join(self._caddy_dir, 'docs')
48 self._conf_file = os.path.join(self._caddy_dir, 'Caddyfile')
49 self._error_log = os.path.join(self._caddy_dir, 'caddy.log')
50 self._tmp_dir = os.path.join(self._caddy_dir, 'tmp')
51 self._process = None
52 self._rmf(self._error_log)
55 def docs_dir(self): argument
56 return self._docs_dir
59 def port(self) -> int: argument
60 return self.env.caddy_https_port
62 def clear_logs(self): argument
63 self._rmf(self._error_log)
65 def is_running(self): argument
66 if self._process:
67 self._process.poll()
68 return self._process.returncode is None
71 def start_if_needed(self): argument
72 if not self.is_running():
73 return self.start()
76 def start(self, wait_live=True): argument
77 self._mkpath(self._tmp_dir)
78 if self._process:
79 self.stop()
80 self._write_config()
82 self._caddy, 'run'
84 caddyerr = open(self._error_log, 'a')
85 self._process = subprocess.Popen(args=args, cwd=self._caddy_dir, stderr=caddyerr)
86 if self._process.returncode is not None:
88 return not wait_live or self.wait_live(timeout=timedelta(seconds=5))
90 def stop_if_running(self): argument
91 if self.is_running():
92 return self.stop()
95 def stop(self, wait_dead=True): argument
96 self._mkpath(self._tmp_dir)
97 if self._process:
98 self._process.terminate()
99 self._process.wait(timeout=2)
100 self._process = None
101 return not wait_dead or self.wait_dead(timeout=timedelta(seconds=5))
104 def restart(self): argument
105 self.stop()
106 return self.start()
108 def wait_dead(self, timeout: timedelta): argument
109 curl = CurlClient(env=self.env, run_dir=self._tmp_dir)
121 def wait_live(self, timeout: timedelta): argument
122 curl = CurlClient(env=self.env, run_dir=self._tmp_dir)
133 def _rmf(self, path): argument
137 def _mkpath(self, path): argument
141 def _write_config(self): argument
142 domain1 = self.env.domain1
143 creds1 = self.env.get_credentials(domain1)
145 domain2 = self.env.domain2
146 creds2 = self.env.get_credentials(domain2)
148 self._mkpath(self._docs_dir)
149 self._mkpath(self._tmp_dir)
150 with open(os.path.join(self._docs_dir, 'data.json'), 'w') as fd:
155 with open(self._conf_file, 'w') as fd: