Skip to content

Commit

Permalink
add error handling to support tunnel endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rtertiaer committed Jun 10, 2024
1 parent 7f3e8eb commit 2a7a196
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions amplipi/updater/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,16 @@ def set_admin_password(input: PasswordInput):
@router.post('/support')
def request_support():
""" Creates a support tunnel request. """
out = subprocess.run(
'/opt/support_tunnel/venv/bin/python3 -m invoke request'.split(),
capture_output=True,
cwd='/opt/support_tunnel'
)
return Response(content=f"{out.stdout.decode('utf')}", media_type="text/html")
try:
out = subprocess.run(
'/opt/support_tunnel/venv/bin/python3 -m invoke request'.split(),
capture_output=True,
cwd='/opt/support_tunnel',
timeout=120
)
return Response(content=f"{out.stdout.decode('utf')}", media_type="text/html")
except Exception as e:
return Response(content=f"failed to request tunnel: {e}", media_type="text/html")


app.include_router(auth_router)
Expand Down

0 comments on commit 2a7a196

Please sign in to comment.