Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote: add support for pystuck #1572

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions labgrid/remote/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,9 @@ async def serve(listen, cleanup) -> None:
logging.debug("Starting server")
await server.start()

if inspect:
inspect.coordinator = coordinator

async def server_graceful_shutdown():
logging.info("Starting graceful shutdown...")
# Shuts down the server with 0 seconds of grace period. During the
Expand All @@ -1025,6 +1028,10 @@ def main():
help="coordinator listening host and port",
)
parser.add_argument("-d", "--debug", action="store_true", default=False, help="enable debug mode")
parser.add_argument("--pystuck", action="store_true", help="enable pystuck")
parser.add_argument(
"--pystuck-port", metavar="PORT", type=int, default=6666, help="use a different pystuck port than 6666"
)

args = parser.parse_args()

Expand All @@ -1033,6 +1040,19 @@ def main():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

global inspect
if args.pystuck:
from types import SimpleNamespace

inspect = SimpleNamespace()
inspect.loop = loop

import pystuck

pystuck.run_server(port=args.pystuck_port)
else:
inspect = None

cleanup = []
loop.set_debug(True)
try:
Expand Down
21 changes: 21 additions & 0 deletions labgrid/remote/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,10 @@ async def update_resource(self, group_name, resource_name):

async def amain(config) -> bool:
exporter = Exporter(config)

if inspect:
inspect.exporter = exporter

await exporter.run()


Expand Down Expand Up @@ -1044,6 +1048,10 @@ def main():
default=False,
help="enable isolated mode (always request SSH forwards)",
)
parser.add_argument("--pystuck", action="store_true", help="enable pystuck")
parser.add_argument(
"--pystuck-port", metavar="PORT", type=int, default=6667, help="use a different pystuck port than 6667"
)
parser.add_argument("resources", metavar="RESOURCES", type=str, help="resource config file name")

args = parser.parse_args()
Expand All @@ -1065,6 +1073,19 @@ def main():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

global inspect
if args.pystuck:
from types import SimpleNamespace

inspect = SimpleNamespace()
inspect.loop = loop

import pystuck

pystuck.run_server(port=args.pystuck_port)
else:
inspect = None

asyncio.run(amain(config), debug=bool(args.debug))

if reexec:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ dev = [
"pytest-mock>=3.6.1",
"pylint>=3.0.0",
"ruff>=0.5.7",
"pystuck",

# GRPC Channelz support
"grpcio-channelz>=1.64.1, <2.0.0",
Expand Down