-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunners.py
More file actions
21 lines (19 loc) · 715 Bytes
/
runners.py
File metadata and controls
21 lines (19 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3
"""
manage_runners.py start|stop
Starts or stops every self-hosted runner found under RUNNERS_ROOT.
"""
import pathlib, subprocess, sys
RUNNERS_ROOT = pathlib.Path.home() / "gh-runners" # same parent as above
def runner_dirs():
return [p for p in RUNNERS_ROOT.iterdir() if (p / "svc.sh").exists()]
def main():
if len(sys.argv) != 2 or sys.argv[1] not in {"start", "stop"}:
sys.exit("Usage: manage_runners.py start|stop")
action = sys.argv[1]
for path in runner_dirs():
subprocess.call([str(path / "svc.sh"), action], cwd=path)
print(f"{action.title():<5} {path.name}")
print(f"\nAll runners {action}ed.")
if __name__ == "__main__":
main()