redeploy 0.2.29__tar.gz → 0.2.31__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {redeploy-0.2.29 → redeploy-0.2.31}/PKG-INFO +6 -6
- {redeploy-0.2.29 → redeploy-0.2.31}/README.md +5 -5
- {redeploy-0.2.29 → redeploy-0.2.31}/pyproject.toml +1 -1
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/__init__.py +1 -1
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/devices.py +14 -4
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/discovery.py +44 -3
- redeploy-0.2.31/redeploy/plugins/builtin/hardware_diagnostic.py +282 -0
- redeploy-0.2.31/redeploy/plugins/builtin/process_control.py +123 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/steps.py +34 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy.egg-info/PKG-INFO +6 -6
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy.egg-info/SOURCES.txt +2 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/apply/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/apply/exceptions.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/apply/executor.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/apply/handlers.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/apply/progress.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/apply/rollback.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/apply/state.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/audit.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/audit.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/detect.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/diagnose.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/diff.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/exec_.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/export.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/import_.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/init.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/inspect.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/patterns.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/plan_apply.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/plugin.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/probe.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/state.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/status.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/target.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/version.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/commands/workflow.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/core.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli/display.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/cli.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/data_sync.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/detect/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/detect/detector.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/detect/probes.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/detect/remote.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/detect/templates.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/detect/workflow.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl/loader.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl/parser.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl_python/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl_python/context.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl_python/decorators.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl_python/docker_steps.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl_python/exceptions.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl_python/runner.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/dsl_python/steps.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/fleet.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/iac/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/iac/base.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/iac/docker_compose.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/iac/parsers/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/iac/parsers/compose.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/iac/registry.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/markpact/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/markpact/compiler.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/markpact/models.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/markpact/parser.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/models.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/observe.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/parse.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/patterns.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/plan/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/plan/planner.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/plugins/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/plugins/builtin/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/plugins/builtin/browser_reload.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/plugins/builtin/notify.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/plugins/builtin/systemd_reload.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/spec_loader.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/ssh.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_audit.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_cli.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_data_sync.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_discovery.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_dsl.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_examples.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_executor.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_fleet.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_git_integration.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_iac.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_manifest.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_markpact_compiler.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_markpact_parser.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_models.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_observe.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_parse.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_patterns.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_planner_edge.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_plugins.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_probes.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_public_api.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_resume.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_spec_loader.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_ssh.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_templates.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_verify.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_version.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_version_changelog.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_version_cli.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_version_manifest.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_version_sources.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/tests/test_workflow.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/verify.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/bump.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/changelog.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/commits.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/diff.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/git_integration.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/git_transaction.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/manifest.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/sources/__init__.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/sources/base.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/sources/json_.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/sources/plain.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/sources/regex.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/sources/toml_.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/sources/yaml_.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version/transaction.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy/version.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy.egg-info/dependency_links.txt +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy.egg-info/entry_points.txt +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy.egg-info/requires.txt +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/redeploy.egg-info/top_level.txt +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/setup.cfg +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/tests/test_iac.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/tests/test_parse.py +0 -0
- {redeploy-0.2.29 → redeploy-0.2.31}/tests/test_redeploy.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: redeploy
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.31
|
|
4
4
|
Summary: Infrastructure migration toolkit: detect → plan → apply
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -27,17 +27,17 @@ Requires-Dist: pfix>=0.1.60; extra == "dev"
|
|
|
27
27
|
|
|
28
28
|
## AI Cost Tracking
|
|
29
29
|
|
|
30
|
-
    
|
|
31
|
+
  
|
|
32
32
|
|
|
33
|
-
- 🤖 **LLM usage:** $7.
|
|
34
|
-
- 👤 **Human dev:** ~$
|
|
33
|
+
- 🤖 **LLM usage:** $7.5000 (51 commits)
|
|
34
|
+
- 👤 **Human dev:** ~$1597 (16.0h @ $100/h, 30min dedup)
|
|
35
35
|
|
|
36
36
|
Generated on 2026-04-21 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
|
|
37
37
|
|
|
38
38
|
---
|
|
39
39
|
|
|
40
|
-
    
|
|
41
41
|
|
|
42
42
|
Infrastructure migration and device deploy toolkit — VPS, Raspberry Pi kiosk, Podman Quadlet, k3s.
|
|
43
43
|
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
|
|
4
4
|
## AI Cost Tracking
|
|
5
5
|
|
|
6
|
-
    
|
|
7
|
+
  
|
|
8
8
|
|
|
9
|
-
- 🤖 **LLM usage:** $7.
|
|
10
|
-
- 👤 **Human dev:** ~$
|
|
9
|
+
- 🤖 **LLM usage:** $7.5000 (51 commits)
|
|
10
|
+
- 👤 **Human dev:** ~$1597 (16.0h @ $100/h, 30min dedup)
|
|
11
11
|
|
|
12
12
|
Generated on 2026-04-21 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
    
|
|
17
17
|
|
|
18
18
|
Infrastructure migration and device deploy toolkit — VPS, Raspberry Pi kiosk, Podman Quadlet, k3s.
|
|
19
19
|
|
|
@@ -7,7 +7,7 @@ Public API (stable from 0.2.0, semver guaranteed)::
|
|
|
7
7
|
|
|
8
8
|
Everything not listed in ``__all__`` is internal and may change without notice.
|
|
9
9
|
"""
|
|
10
|
-
__version__ = "0.2.
|
|
10
|
+
__version__ = "0.2.31"
|
|
11
11
|
|
|
12
12
|
# ── Core models ───────────────────────────────────────────────────────────────
|
|
13
13
|
from .models import ( # noqa: F401
|
|
@@ -13,9 +13,10 @@ from rich.table import Table
|
|
|
13
13
|
@click.command()
|
|
14
14
|
@click.option("--tag", default=None, help="Filter by tag")
|
|
15
15
|
@click.option("--strategy", default=None, help="Filter by strategy")
|
|
16
|
+
@click.option("--rpi", is_flag=True, help="Show only Raspberry Pi devices")
|
|
16
17
|
@click.option("--reachable", is_flag=True, help="Show only recently-seen devices")
|
|
17
18
|
@click.option("--json", "as_json", is_flag=True, help="Output as JSON")
|
|
18
|
-
def devices(tag, strategy, reachable, as_json):
|
|
19
|
+
def devices(tag, strategy, rpi, reachable, as_json):
|
|
19
20
|
"""List known devices from ~/.config/redeploy/devices.yaml.
|
|
20
21
|
|
|
21
22
|
\b
|
|
@@ -35,6 +36,8 @@ def devices(tag, strategy, reachable, as_json):
|
|
|
35
36
|
devs = [d for d in devs if tag in d.tags]
|
|
36
37
|
if strategy:
|
|
37
38
|
devs = [d for d in devs if d.strategy == strategy]
|
|
39
|
+
if rpi:
|
|
40
|
+
devs = [d for d in devs if "raspberry-pi" in d.tags]
|
|
38
41
|
if reachable:
|
|
39
42
|
devs = [d for d in devs if d.is_reachable]
|
|
40
43
|
|
|
@@ -64,12 +67,16 @@ def devices(tag, strategy, reachable, as_json):
|
|
|
64
67
|
for d in devs:
|
|
65
68
|
seen = d.last_seen.strftime("%m-%d %H:%M") if d.last_seen else "never"
|
|
66
69
|
ssh = "[green]✓[/green]" if d.last_ssh_ok else "[red]✗[/red]"
|
|
70
|
+
tags_str = ",".join(d.tags) or "—"
|
|
71
|
+
# Highlight raspberry-pi tag
|
|
72
|
+
if "raspberry-pi" in d.tags:
|
|
73
|
+
tags_str = tags_str.replace("raspberry-pi", "[bold magenta]raspberry-pi[/bold magenta]")
|
|
67
74
|
t.add_row(
|
|
68
75
|
d.id,
|
|
69
76
|
d.host,
|
|
70
77
|
d.strategy,
|
|
71
78
|
d.app or "—",
|
|
72
|
-
|
|
79
|
+
tags_str,
|
|
73
80
|
seen,
|
|
74
81
|
ssh,
|
|
75
82
|
)
|
|
@@ -130,17 +137,20 @@ def scan(subnet, ssh_users, ssh_port, ping, no_mdns, timeout, no_save):
|
|
|
130
137
|
)
|
|
131
138
|
|
|
132
139
|
ssh_ok = [h for h in found if h.ssh_ok]
|
|
133
|
-
|
|
140
|
+
rpi_count = sum(1 for h in found if h.is_raspberry_pi)
|
|
141
|
+
console.print(f" found {len(found)} host(s), {len(ssh_ok)} SSH-accessible, {rpi_count} Raspberry Pi\n")
|
|
134
142
|
|
|
135
143
|
t = Table(show_header=True, box=None, padding=(0, 2))
|
|
136
144
|
t.add_column("IP")
|
|
137
145
|
t.add_column("Hostname", style="dim")
|
|
138
146
|
t.add_column("MAC", style="dim")
|
|
139
147
|
t.add_column("SSH user", style="cyan")
|
|
148
|
+
t.add_column("RPi", style="bold magenta")
|
|
140
149
|
t.add_column("Source", style="dim")
|
|
141
150
|
for h in found:
|
|
142
151
|
ssh_col = f"[green]{h.ssh_user}[/green]" if h.ssh_ok else "[red]✗[/red]"
|
|
143
|
-
|
|
152
|
+
rpi_col = "🍓" if h.is_raspberry_pi else "—"
|
|
153
|
+
t.add_row(h.ip, h.hostname or "—", h.mac or "—", ssh_col, rpi_col, h.source)
|
|
144
154
|
console.print(t)
|
|
145
155
|
|
|
146
156
|
if not no_save and ssh_ok:
|
|
@@ -38,6 +38,24 @@ class DiscoveredHost:
|
|
|
38
38
|
ssh_user: str = ""
|
|
39
39
|
source: str = "unknown"
|
|
40
40
|
ports_open: list[int] = field(default_factory=list)
|
|
41
|
+
is_raspberry_pi: bool = False
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# ── Raspberry Pi identification ─────────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
_RPI_MAC_PREFIXES = [
|
|
47
|
+
"b8:27:eb", # Raspberry Pi Foundation
|
|
48
|
+
"dc:a6:32", # Raspberry Pi Trading
|
|
49
|
+
"e4:5f:01", # Raspberry Pi Trading
|
|
50
|
+
"28:cd:c1", # Raspberry Pi 5
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
def _is_raspberry_pi_mac(mac: str) -> bool:
|
|
54
|
+
"""Check if MAC address belongs to Raspberry Pi."""
|
|
55
|
+
if not mac:
|
|
56
|
+
return False
|
|
57
|
+
mac_prefix = mac[:8].lower()
|
|
58
|
+
return mac_prefix in _RPI_MAC_PREFIXES
|
|
41
59
|
|
|
42
60
|
|
|
43
61
|
# ── Individual scanners ───────────────────────────────────────────────────────
|
|
@@ -89,7 +107,12 @@ def _scan_arp_cache() -> list[DiscoveredHost]:
|
|
|
89
107
|
parts = line.split()
|
|
90
108
|
if len(parts) >= 5 and re.match(r"\d+\.\d+\.\d+\.\d+", parts[0]):
|
|
91
109
|
mac = parts[4] if len(parts) > 4 else ""
|
|
92
|
-
results.append(DiscoveredHost(
|
|
110
|
+
results.append(DiscoveredHost(
|
|
111
|
+
ip=parts[0],
|
|
112
|
+
mac=mac,
|
|
113
|
+
source="arp",
|
|
114
|
+
is_raspberry_pi=_is_raspberry_pi_mac(mac)
|
|
115
|
+
))
|
|
93
116
|
if results:
|
|
94
117
|
logger.debug(f"arp (ip neigh): {len(results)} hosts")
|
|
95
118
|
return results
|
|
@@ -101,7 +124,13 @@ def _scan_arp_cache() -> list[DiscoveredHost]:
|
|
|
101
124
|
# ? (192.168.1.1) at aa:bb:cc:dd:ee:ff [ether] on eth0
|
|
102
125
|
m = re.search(r"\((\d+\.\d+\.\d+\.\d+)\).*?([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f:]+)", line, re.I)
|
|
103
126
|
if m:
|
|
104
|
-
|
|
127
|
+
mac = m.group(2)
|
|
128
|
+
results.append(DiscoveredHost(
|
|
129
|
+
ip=m.group(1),
|
|
130
|
+
mac=mac,
|
|
131
|
+
source="arp",
|
|
132
|
+
is_raspberry_pi=_is_raspberry_pi_mac(mac)
|
|
133
|
+
))
|
|
105
134
|
logger.debug(f"arp: {len(results)} hosts")
|
|
106
135
|
return results
|
|
107
136
|
|
|
@@ -250,6 +279,8 @@ def _merge(hosts: list[DiscoveredHost]) -> list[DiscoveredHost]:
|
|
|
250
279
|
existing.ssh_user = existing.ssh_user or h.ssh_user
|
|
251
280
|
if existing.source == "unknown":
|
|
252
281
|
existing.source = h.source
|
|
282
|
+
if h.is_raspberry_pi:
|
|
283
|
+
existing.is_raspberry_pi = True
|
|
253
284
|
else:
|
|
254
285
|
by_ip[h.ip] = h
|
|
255
286
|
return list(by_ip.values())
|
|
@@ -302,6 +333,11 @@ def discover(
|
|
|
302
333
|
|
|
303
334
|
found = _merge(found)
|
|
304
335
|
|
|
336
|
+
# Log Raspberry Pi devices
|
|
337
|
+
rpi_devices = [h for h in found if h.is_raspberry_pi]
|
|
338
|
+
if rpi_devices:
|
|
339
|
+
logger.info(f"Found {len(rpi_devices)} Raspberry Pi device(s): {', '.join(h.ip for h in rpi_devices)}")
|
|
340
|
+
|
|
305
341
|
# SSH probe
|
|
306
342
|
if probe_ssh and found:
|
|
307
343
|
logger.info(f"SSH probe: {len(found)} hosts ({timeout}s timeout each)")
|
|
@@ -339,9 +375,14 @@ def update_registry(
|
|
|
339
375
|
existing.hostname = h.hostname
|
|
340
376
|
if h.ssh_ok:
|
|
341
377
|
existing.last_ssh_ok = now
|
|
378
|
+
if h.is_raspberry_pi and "raspberry-pi" not in existing.tags:
|
|
379
|
+
existing.tags.append("raspberry-pi")
|
|
342
380
|
reg.upsert(existing)
|
|
343
381
|
elif h.ssh_ok:
|
|
344
382
|
# Only auto-add SSH-accessible devices
|
|
383
|
+
tags = ["discovered"]
|
|
384
|
+
if h.is_raspberry_pi:
|
|
385
|
+
tags.append("raspberry-pi")
|
|
345
386
|
reg.upsert(KnownDevice(
|
|
346
387
|
id=device_id,
|
|
347
388
|
host=device_id,
|
|
@@ -352,7 +393,7 @@ def update_registry(
|
|
|
352
393
|
last_seen=now,
|
|
353
394
|
last_ssh_ok=now,
|
|
354
395
|
source=h.source,
|
|
355
|
-
tags=
|
|
396
|
+
tags=tags,
|
|
356
397
|
))
|
|
357
398
|
|
|
358
399
|
if save:
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"""Hardware diagnostic plugin for redeploy.
|
|
2
|
+
|
|
3
|
+
Analyzes system hardware and provides configuration recommendations.
|
|
4
|
+
Supports Raspberry Pi variants and desktop platforms.
|
|
5
|
+
|
|
6
|
+
Usage in deployment.yaml:
|
|
7
|
+
extra_steps:
|
|
8
|
+
- id: analyze_hardware
|
|
9
|
+
action: plugin
|
|
10
|
+
plugin_type: hardware_diagnostic
|
|
11
|
+
plugin_params:
|
|
12
|
+
checks: ["platform", "cpu", "memory", "storage", "gpio", "usb", "audio"]
|
|
13
|
+
platform: "auto" # or "rpi3", "rpi4", "rpi5", "desktop"
|
|
14
|
+
verbose: true
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import os
|
|
19
|
+
import subprocess
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from typing import Any, Dict, List, Optional
|
|
22
|
+
|
|
23
|
+
from loguru import logger
|
|
24
|
+
|
|
25
|
+
from redeploy.plugins import PluginContext, register_plugin
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class HardwareInfo:
|
|
30
|
+
"""Hardware diagnostic information."""
|
|
31
|
+
platform: str
|
|
32
|
+
cpu_model: str
|
|
33
|
+
cpu_cores: int
|
|
34
|
+
memory_mb: int
|
|
35
|
+
storage_gb: float
|
|
36
|
+
gpio_available: bool
|
|
37
|
+
usb_devices: List[str]
|
|
38
|
+
audio_devices: List[str]
|
|
39
|
+
network_interfaces: List[str]
|
|
40
|
+
issues: List[str]
|
|
41
|
+
recommendations: List[str]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _run_command(cmd: str) -> str:
|
|
45
|
+
"""Run shell command and return output."""
|
|
46
|
+
try:
|
|
47
|
+
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10)
|
|
48
|
+
return result.stdout.strip()
|
|
49
|
+
except Exception as e:
|
|
50
|
+
logger.debug(f"Command failed: {cmd} - {e}")
|
|
51
|
+
return ""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _detect_platform() -> str:
|
|
55
|
+
"""Detect the platform type."""
|
|
56
|
+
# Check for Raspberry Pi
|
|
57
|
+
model_file = "/proc/device-tree/model"
|
|
58
|
+
if os.path.exists(model_file):
|
|
59
|
+
try:
|
|
60
|
+
with open(model_file, "r") as f:
|
|
61
|
+
model = f.read().strip("\x00")
|
|
62
|
+
if "Raspberry Pi 5" in model:
|
|
63
|
+
return "rpi5"
|
|
64
|
+
elif "Raspberry Pi 4" in model:
|
|
65
|
+
return "rpi4"
|
|
66
|
+
elif "Raspberry Pi 3" in model:
|
|
67
|
+
return "rpi3"
|
|
68
|
+
except Exception:
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
# Check CPU info
|
|
72
|
+
cpuinfo = _run_command("cat /proc/cpuinfo")
|
|
73
|
+
if "Raspberry Pi" in cpuinfo or "BCM" in cpuinfo:
|
|
74
|
+
return "rpi_unknown"
|
|
75
|
+
|
|
76
|
+
# Check architecture
|
|
77
|
+
arch = _run_command("uname -m")
|
|
78
|
+
if arch == "aarch64":
|
|
79
|
+
return "arm64_unknown"
|
|
80
|
+
elif arch == "x86_64":
|
|
81
|
+
return "desktop"
|
|
82
|
+
|
|
83
|
+
return "unknown"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _get_cpu_info() -> tuple[str, int]:
|
|
87
|
+
"""Get CPU model and core count."""
|
|
88
|
+
cpuinfo = _run_command("cat /proc/cpuinfo")
|
|
89
|
+
model = "unknown"
|
|
90
|
+
cores = 0
|
|
91
|
+
|
|
92
|
+
for line in cpuinfo.split("\n"):
|
|
93
|
+
if line.startswith("model name"):
|
|
94
|
+
model = line.split(":", 1)[1].strip()
|
|
95
|
+
elif line.startswith("Hardware"):
|
|
96
|
+
model = line.split(":", 1)[1].strip()
|
|
97
|
+
elif line.startswith("processor"):
|
|
98
|
+
cores += 1
|
|
99
|
+
|
|
100
|
+
return model, max(cores, 1)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _get_memory_mb() -> int:
|
|
104
|
+
"""Get total memory in MB."""
|
|
105
|
+
meminfo = _run_command("cat /proc/meminfo")
|
|
106
|
+
for line in meminfo.split("\n"):
|
|
107
|
+
if line.startswith("MemTotal"):
|
|
108
|
+
kb = int(line.split()[1])
|
|
109
|
+
return kb // 1024
|
|
110
|
+
return 0
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _get_storage_gb() -> float:
|
|
114
|
+
"""Get available storage in GB."""
|
|
115
|
+
output = _run_command("df -h /")
|
|
116
|
+
if output:
|
|
117
|
+
lines = output.split("\n")
|
|
118
|
+
if len(lines) > 1:
|
|
119
|
+
parts = lines[1].split()
|
|
120
|
+
if len(parts) > 3:
|
|
121
|
+
available = parts[3]
|
|
122
|
+
if available.endswith("G"):
|
|
123
|
+
return float(available.rstrip("G"))
|
|
124
|
+
elif available.endswith("M"):
|
|
125
|
+
return float(available.rstrip("M")) / 1024
|
|
126
|
+
return 0.0
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _check_gpio() -> bool:
|
|
130
|
+
"""Check if GPIO is available."""
|
|
131
|
+
# Check for GPIO character device
|
|
132
|
+
return os.path.exists("/dev/gpiochip0") or os.path.exists("/dev/gpiomem")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _get_usb_devices() -> List[str]:
|
|
136
|
+
"""Get list of USB devices."""
|
|
137
|
+
output = _run_command("lsusb")
|
|
138
|
+
devices = []
|
|
139
|
+
for line in output.split("\n"):
|
|
140
|
+
if line:
|
|
141
|
+
parts = line.split(" ", 6)
|
|
142
|
+
if len(parts) > 6:
|
|
143
|
+
devices.append(parts[6])
|
|
144
|
+
return devices
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _get_audio_devices() -> List[str]:
|
|
148
|
+
"""Get list of audio devices."""
|
|
149
|
+
output = _run_command("aplay -l")
|
|
150
|
+
devices = []
|
|
151
|
+
for line in output.split("\n"):
|
|
152
|
+
if line.startswith("card"):
|
|
153
|
+
devices.append(line.strip())
|
|
154
|
+
return devices
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _get_network_interfaces() -> List[str]:
|
|
158
|
+
"""Get list of network interfaces."""
|
|
159
|
+
output = _run_command("ip -o link show")
|
|
160
|
+
interfaces = []
|
|
161
|
+
for line in output.split("\n"):
|
|
162
|
+
if line:
|
|
163
|
+
parts = line.split(":")
|
|
164
|
+
if len(parts) > 1:
|
|
165
|
+
iface = parts[1].strip()
|
|
166
|
+
if iface != "lo":
|
|
167
|
+
interfaces.append(iface)
|
|
168
|
+
return interfaces
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _analyze_hardware(platform: str, verbose: bool = False) -> HardwareInfo:
|
|
172
|
+
"""Perform comprehensive hardware analysis."""
|
|
173
|
+
platform = platform if platform != "auto" else _detect_platform()
|
|
174
|
+
cpu_model, cpu_cores = _get_cpu_info()
|
|
175
|
+
memory_mb = _get_memory_mb()
|
|
176
|
+
storage_gb = _get_storage_gb()
|
|
177
|
+
gpio_available = _check_gpio()
|
|
178
|
+
usb_devices = _get_usb_devices()
|
|
179
|
+
audio_devices = _get_audio_devices()
|
|
180
|
+
network_interfaces = _get_network_interfaces()
|
|
181
|
+
|
|
182
|
+
issues = []
|
|
183
|
+
recommendations = []
|
|
184
|
+
|
|
185
|
+
# Platform-specific checks
|
|
186
|
+
if platform.startswith("rpi"):
|
|
187
|
+
if memory_mb < 1024:
|
|
188
|
+
issues.append(f"Low memory: {memory_mb}MB (recommended: >= 2GB for RPi)")
|
|
189
|
+
recommendations.append("Consider upgrading to RPi4/5 with 2GB+ RAM")
|
|
190
|
+
if storage_gb < 5:
|
|
191
|
+
issues.append(f"Low storage: {storage_gb}GB (recommended: >= 8GB)")
|
|
192
|
+
recommendations.append("Free up disk space or use larger SD card")
|
|
193
|
+
|
|
194
|
+
if platform == "rpi5":
|
|
195
|
+
if not gpio_available:
|
|
196
|
+
issues.append("GPIO not available on RPi5")
|
|
197
|
+
recommendations.append("Check kernel configuration for GPIO support")
|
|
198
|
+
elif platform in ["rpi3", "rpi4"]:
|
|
199
|
+
if not gpio_available:
|
|
200
|
+
issues.append("GPIO not available")
|
|
201
|
+
recommendations.append("Enable GPIO in config.txt or check permissions")
|
|
202
|
+
|
|
203
|
+
elif platform == "desktop":
|
|
204
|
+
if memory_mb < 4096:
|
|
205
|
+
issues.append(f"Low memory: {memory_mb}MB (recommended: >= 4GB for desktop)")
|
|
206
|
+
recommendations.append("Consider upgrading RAM for better performance")
|
|
207
|
+
|
|
208
|
+
# General checks
|
|
209
|
+
if not network_interfaces:
|
|
210
|
+
issues.append("No network interfaces detected")
|
|
211
|
+
recommendations.append("Check network configuration")
|
|
212
|
+
|
|
213
|
+
if verbose:
|
|
214
|
+
logger.info(f"Platform: {platform}")
|
|
215
|
+
logger.info(f"CPU: {cpu_model} ({cpu_cores} cores)")
|
|
216
|
+
logger.info(f"Memory: {memory_mb}MB")
|
|
217
|
+
logger.info(f"Storage: {storage_gb}GB available")
|
|
218
|
+
logger.info(f"GPIO: {'Available' if gpio_available else 'Not available'}")
|
|
219
|
+
logger.info(f"USB devices: {len(usb_devices)}")
|
|
220
|
+
logger.info(f"Audio devices: {len(audio_devices)}")
|
|
221
|
+
logger.info(f"Network interfaces: {network_interfaces}")
|
|
222
|
+
|
|
223
|
+
return HardwareInfo(
|
|
224
|
+
platform=platform,
|
|
225
|
+
cpu_model=cpu_model,
|
|
226
|
+
cpu_cores=cpu_cores,
|
|
227
|
+
memory_mb=memory_mb,
|
|
228
|
+
storage_gb=storage_gb,
|
|
229
|
+
gpio_available=gpio_available,
|
|
230
|
+
usb_devices=usb_devices,
|
|
231
|
+
audio_devices=audio_devices,
|
|
232
|
+
network_interfaces=network_interfaces,
|
|
233
|
+
issues=issues,
|
|
234
|
+
recommendations=recommendations,
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
@register_plugin("hardware_diagnostic")
|
|
239
|
+
def hardware_diagnostic(ctx: PluginContext) -> None:
|
|
240
|
+
"""Perform hardware diagnostics and provide recommendations."""
|
|
241
|
+
checks = ctx.params.get("checks", ["platform", "cpu", "memory", "storage"])
|
|
242
|
+
platform = ctx.params.get("platform", "auto")
|
|
243
|
+
verbose = ctx.params.get("verbose", True)
|
|
244
|
+
dry_run = ctx.dry_run
|
|
245
|
+
|
|
246
|
+
if dry_run:
|
|
247
|
+
logger.info("[DRY RUN] Would analyze hardware")
|
|
248
|
+
ctx.step.status = "done"
|
|
249
|
+
ctx.step.result = "dry_run"
|
|
250
|
+
return
|
|
251
|
+
|
|
252
|
+
logger.info("Starting hardware diagnostic...")
|
|
253
|
+
|
|
254
|
+
hw_info = _analyze_hardware(platform, verbose)
|
|
255
|
+
|
|
256
|
+
# Build result message
|
|
257
|
+
result_parts = []
|
|
258
|
+
result_parts.append(f"Platform: {hw_info.platform}")
|
|
259
|
+
result_parts.append(f"CPU: {hw_info.cpu_model} ({hw_info.cpu_cores} cores)")
|
|
260
|
+
result_parts.append(f"Memory: {hw_info.memory_mb}MB")
|
|
261
|
+
result_parts.append(f"Storage: {hw_info.storage_gb}GB")
|
|
262
|
+
result_parts.append(f"GPIO: {'OK' if hw_info.gpio_available else 'N/A'}")
|
|
263
|
+
|
|
264
|
+
if hw_info.issues:
|
|
265
|
+
result_parts.append(f"Issues: {len(hw_info.issues)}")
|
|
266
|
+
for issue in hw_info.issues:
|
|
267
|
+
logger.warning(f" - {issue}")
|
|
268
|
+
|
|
269
|
+
if hw_info.recommendations:
|
|
270
|
+
result_parts.append(f"Recommendations: {len(hw_info.recommendations)}")
|
|
271
|
+
for rec in hw_info.recommendations:
|
|
272
|
+
logger.info(f" - {rec}")
|
|
273
|
+
|
|
274
|
+
ctx.step.result = "; ".join(result_parts)
|
|
275
|
+
ctx.step.description = f"Hardware diagnostic: {hw_info.platform}, {hw_info.memory_mb}MB RAM"
|
|
276
|
+
|
|
277
|
+
if hw_info.issues:
|
|
278
|
+
ctx.step.status = "done" # Still done, but with warnings
|
|
279
|
+
logger.warning(f"Hardware diagnostic completed with {len(hw_info.issues)} issues")
|
|
280
|
+
else:
|
|
281
|
+
ctx.step.status = "done"
|
|
282
|
+
logger.info("Hardware diagnostic completed successfully")
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Process control plugin for redeploy.
|
|
2
|
+
|
|
3
|
+
Automatically kills processes on specified ports before deployment.
|
|
4
|
+
Supports port ranges, process name filtering, and graceful vs force kill.
|
|
5
|
+
|
|
6
|
+
Usage in deployment.yaml:
|
|
7
|
+
extra_steps:
|
|
8
|
+
- id: kill_processes_on_ports
|
|
9
|
+
action: plugin
|
|
10
|
+
plugin_type: process_control
|
|
11
|
+
plugin_params:
|
|
12
|
+
ports: [8100, 8101, 8202]
|
|
13
|
+
strategy: graceful # or 'force'
|
|
14
|
+
timeout: 10
|
|
15
|
+
notify: true
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import socket
|
|
20
|
+
import time
|
|
21
|
+
from typing import Optional
|
|
22
|
+
|
|
23
|
+
from loguru import logger
|
|
24
|
+
|
|
25
|
+
from redeploy.models import ConflictSeverity, MigrationStep
|
|
26
|
+
from redeploy.plugins import PluginContext, register_plugin
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _find_pid_on_port(port: int) -> Optional[int]:
|
|
30
|
+
"""Find PID of process listening on port (Linux only)."""
|
|
31
|
+
try:
|
|
32
|
+
with open("/proc/net/tcp", "r") as f:
|
|
33
|
+
for line in f:
|
|
34
|
+
parts = line.strip().split()
|
|
35
|
+
if len(parts) >= 10:
|
|
36
|
+
# Format: local_addr rem_addr st tx_queue rx_queue ...
|
|
37
|
+
# local_addr format: hex_ip:hex_port
|
|
38
|
+
local_addr = parts[1].split(":")[-1]
|
|
39
|
+
hex_port = int(local_addr, 16)
|
|
40
|
+
if hex_port == port:
|
|
41
|
+
inode = parts[9]
|
|
42
|
+
# Find PID by inode in /proc/*/fd
|
|
43
|
+
import os
|
|
44
|
+
for pid_dir in os.listdir("/proc"):
|
|
45
|
+
if pid_dir.isdigit():
|
|
46
|
+
fd_dir = f"/proc/{pid_dir}/fd"
|
|
47
|
+
if os.path.exists(fd_dir):
|
|
48
|
+
for fd in os.listdir(fd_dir):
|
|
49
|
+
try:
|
|
50
|
+
link = os.readlink(os.path.join(fd_dir, fd))
|
|
51
|
+
if f"socket:[{inode}]" in link:
|
|
52
|
+
return int(pid_dir)
|
|
53
|
+
except (OSError, ValueError):
|
|
54
|
+
continue
|
|
55
|
+
except Exception as e:
|
|
56
|
+
logger.debug(f"Could not find PID on port {port}: {e}")
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _kill_process(pid: int, force: bool = False) -> bool:
|
|
61
|
+
"""Kill a process by PID. Returns True if successful."""
|
|
62
|
+
try:
|
|
63
|
+
import os
|
|
64
|
+
import signal
|
|
65
|
+
sig = signal.SIGKILL if force else signal.SIGTERM
|
|
66
|
+
os.kill(pid, sig)
|
|
67
|
+
return True
|
|
68
|
+
except ProcessLookupError:
|
|
69
|
+
return False
|
|
70
|
+
except PermissionError:
|
|
71
|
+
logger.warning(f"Permission denied to kill PID {pid}")
|
|
72
|
+
return False
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@register_plugin("process_control")
|
|
76
|
+
def process_control(ctx: PluginContext) -> None:
|
|
77
|
+
"""Kill processes on specified ports."""
|
|
78
|
+
ports = ctx.params.get("ports", [])
|
|
79
|
+
strategy = ctx.params.get("strategy", "graceful")
|
|
80
|
+
timeout = ctx.params.get("timeout", 10)
|
|
81
|
+
notify = ctx.params.get("notify", True)
|
|
82
|
+
dry_run = ctx.dry_run
|
|
83
|
+
|
|
84
|
+
if not ports:
|
|
85
|
+
logger.warning("process_control: no ports specified")
|
|
86
|
+
ctx.step.status = "done"
|
|
87
|
+
ctx.step.result = "no_ports"
|
|
88
|
+
return
|
|
89
|
+
|
|
90
|
+
if dry_run:
|
|
91
|
+
logger.info(f"[DRY RUN] Would kill processes on ports: {ports}")
|
|
92
|
+
ctx.step.status = "done"
|
|
93
|
+
ctx.step.result = "dry_run"
|
|
94
|
+
return
|
|
95
|
+
|
|
96
|
+
killed = []
|
|
97
|
+
for port in ports:
|
|
98
|
+
pid = _find_pid_on_port(port)
|
|
99
|
+
if pid:
|
|
100
|
+
logger.info(f"Found process PID {pid} on port {port}")
|
|
101
|
+
if strategy == "graceful":
|
|
102
|
+
_kill_process(pid, force=False)
|
|
103
|
+
# Wait for graceful shutdown
|
|
104
|
+
time.sleep(2)
|
|
105
|
+
# Check if still running
|
|
106
|
+
if _find_pid_on_port(port) == pid:
|
|
107
|
+
logger.warning(f"Process {pid} on port {port} did not stop gracefully, force killing")
|
|
108
|
+
_kill_process(pid, force=True)
|
|
109
|
+
else:
|
|
110
|
+
_kill_process(pid, force=True)
|
|
111
|
+
killed.append((port, pid))
|
|
112
|
+
else:
|
|
113
|
+
logger.debug(f"No process found on port {port}")
|
|
114
|
+
|
|
115
|
+
if killed:
|
|
116
|
+
ctx.step.result = f"killed:{len(killed)}_processes"
|
|
117
|
+
if notify:
|
|
118
|
+
ctx.step.description = f"Killed {len(killed)} process(es) on ports {ports}"
|
|
119
|
+
else:
|
|
120
|
+
ctx.step.result = "no_processes_to_kill"
|
|
121
|
+
ctx.step.description = f"No processes found on ports {ports}"
|
|
122
|
+
|
|
123
|
+
ctx.step.status = "done"
|