MCPcopy Create free account
hub / github.com/FastLED/FastLED / _start_docker_linux

Function _start_docker_linux

ci/util/docker_helper.py:369–422  ·  view source on GitHub ↗

Attempt to start Docker daemon on Linux. Returns: Tuple of (success, message)

()

Source from the content-addressed store, hash-verified

367
368
369def _start_docker_linux() -> tuple[bool, str]:
370 """Attempt to start Docker daemon on Linux.
371
372 Returns:
373 Tuple of (success, message)
374 """
375 try:
376 # Try systemctl first (modern systems)
377 try:
378 result = subprocess.run(
379 ["sudo", "systemctl", "start", "docker"],
380 capture_output=True,
381 text=True,
382 timeout=30,
383 check=False,
384 )
385 if result.returncode == 0:
386 # Wait for Docker to be ready
387 for _ in range(30):
388 time.sleep(1)
389 if is_docker_available():
390 return True, "Docker daemon started via systemctl"
391 return False, "Docker daemon started but is not responding"
392 except FileNotFoundError:
393 pass
394
395 # Try service command (older systems)
396 try:
397 result = subprocess.run(
398 ["sudo", "service", "docker", "start"],
399 capture_output=True,
400 text=True,
401 timeout=30,
402 check=False,
403 )
404 if result.returncode == 0:
405 # Wait for Docker to be ready
406 for _ in range(30):
407 time.sleep(1)
408 if is_docker_available():
409 return True, "Docker daemon started via service"
410 return False, "Docker daemon started but is not responding"
411 except FileNotFoundError:
412 pass
413
414 return (
415 False,
416 "Could not find systemctl or service command. Please ensure Docker is installed.",
417 )
418 except KeyboardInterrupt as ki:
419 handle_keyboard_interrupt(ki)
420 raise
421 except Exception:
422 return False, "Failed to start Docker: Unknown error"

Callers 1

attempt_start_dockerFunction · 0.85

Calls 3

is_docker_availableFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected