(self, config: str = None)
| 46 | self._log = None |
| 47 | |
| 48 | def start(self, config: str = None): |
| 49 | if config is not None and config != self._current: |
| 50 | # change, tear down and start again |
| 51 | assert config in self.configs |
| 52 | self.stop() |
| 53 | self._current = config |
| 54 | elif self._pebble is not None: |
| 55 | # already running |
| 56 | return |
| 57 | args = ['pebble', '-config', self.configs[self._current], '-dnsserver', ':8053'] |
| 58 | env = {} |
| 59 | env.update(os.environ) |
| 60 | env['PEBBLE_VA_NOSLEEP'] = '1' |
| 61 | self._log = open(f'{self.env.gen_dir}/pebble.log', 'w') |
| 62 | self._pebble = subprocess.Popen(args=args, env=env, |
| 63 | stdout=self._log, stderr=self._log) |
| 64 | t = Thread(target=monitor_proc, args=(self.env, self._pebble)) |
| 65 | t.start() |
| 66 | |
| 67 | args = ['pebble-challtestsrv', '-http01', '', '-https01', '', '-tlsalpn01', ''] |
| 68 | self._challtestsrv = subprocess.Popen(args, stdout=self._log, stderr=self._log) |
| 69 | t = Thread(target=monitor_proc, args=(self.env, self._challtestsrv)) |
| 70 | t.start() |
| 71 | self.install_ca_bundle(self.env.acme_ca_pemfile) |
| 72 | # disable ipv6 default address, this gives trouble inside docker |
| 73 | end = datetime.now() + timedelta(seconds=5) |
| 74 | while True: |
| 75 | r = self.env.run(['curl', 'localhost:8055/']) |
| 76 | if r.exit_code == 0: |
| 77 | break |
| 78 | if datetime.now() > end: |
| 79 | raise TimeoutError(f'unable to contact pebble-challtestsrv on localhost:8055') |
| 80 | time.sleep(.1) |
| 81 | r = self.env.run(['curl', '-d', f'{{"ip":""}}', |
| 82 | 'localhost:8055/set-default-ipv6']) |
| 83 | assert r.exit_code == 0, f"{r}" |
| 84 | |
| 85 | def stop(self): |
| 86 | if self._pebble: |
nothing calls this directly
no test coverage detected