Start the server with waitress-serve in process flavor.
(
self,
app_module=None,
application_name="app",
raw_command=None,
port=8050,
start_timeout=3,
)
| 303 | |
| 304 | # pylint: disable=arguments-differ |
| 305 | def start( |
| 306 | self, |
| 307 | app_module=None, |
| 308 | application_name="app", |
| 309 | raw_command=None, |
| 310 | port=8050, |
| 311 | start_timeout=3, |
| 312 | ): |
| 313 | """Start the server with waitress-serve in process flavor.""" |
| 314 | if not (app_module or raw_command): # need to set a least one |
| 315 | logging.error( |
| 316 | "the process runner needs to start with at least one valid command" |
| 317 | ) |
| 318 | return |
| 319 | self.port = port |
| 320 | args = shlex.split( |
| 321 | raw_command |
| 322 | if raw_command |
| 323 | else f"waitress-serve --listen=0.0.0.0:{port} {app_module}:{application_name}.server", |
| 324 | posix=not self.is_windows, |
| 325 | ) |
| 326 | |
| 327 | logger.debug("start dash process with %s", args) |
| 328 | |
| 329 | try: |
| 330 | self.proc = subprocess.Popen( # pylint: disable=consider-using-with |
| 331 | args, stdout=subprocess.PIPE, stderr=subprocess.PIPE |
| 332 | ) |
| 333 | # wait until server is able to answer http request |
| 334 | wait.until(lambda: self.accessible(self.url), timeout=start_timeout) |
| 335 | |
| 336 | except (OSError, ValueError): |
| 337 | logger.exception("process server has encountered an error") |
| 338 | self.started = False |
| 339 | self.stop() |
| 340 | return |
| 341 | |
| 342 | self.started = True |
| 343 | |
| 344 | def stop(self): |
| 345 | if self.proc: |
nothing calls this directly
no test coverage detected