(
host, # type: str
port, # type: int
timeout, # type: float
max_connection_retries, # type: int
request_timeout, # type: int
)
| 204 | |
| 205 | |
| 206 | def launch( |
| 207 | host, # type: str |
| 208 | port, # type: int |
| 209 | timeout, # type: float |
| 210 | max_connection_retries, # type: int |
| 211 | request_timeout, # type: int |
| 212 | ): |
| 213 | # type: (...) -> Union[str, LaunchResult] |
| 214 | |
| 215 | pidfile = Pidfile.load() |
| 216 | if pidfile and pidfile.alive(): |
| 217 | return LaunchResult(url=pidfile.url, already_running=True) |
| 218 | |
| 219 | devpi_server = ensure_devpi_server() |
| 220 | |
| 221 | log = os.path.join(DEVPI_DIR, "log.txt") |
| 222 | with safe_open(log, "w") as fp: |
| 223 | process = launch_python_daemon( |
| 224 | args=devpi_server.launch_args( |
| 225 | "--host", |
| 226 | host, |
| 227 | "--port", |
| 228 | str(port), |
| 229 | "--replica-max-retries", |
| 230 | str(max_connection_retries), |
| 231 | "--request-timeout", |
| 232 | str(request_timeout), |
| 233 | ), |
| 234 | cwd=DEVPI_DIR, |
| 235 | stdout=fp.fileno(), |
| 236 | stderr=subprocess.STDOUT, |
| 237 | ) |
| 238 | |
| 239 | pidfile = Pidfile.record(log=log, pid=process.pid, timeout=timeout) |
| 240 | if not pidfile: |
| 241 | try: |
| 242 | psutil.Process(process.pid).kill() |
| 243 | except psutil.Error as e: |
| 244 | if not isinstance(e, psutil.NoSuchProcess): |
| 245 | raise |
| 246 | return log |
| 247 | |
| 248 | return LaunchResult(url=pidfile.url, already_running=False) |
| 249 | |
| 250 | |
| 251 | def shutdown(): |
nothing calls this directly
no test coverage detected