Skip to content

Commit 6d7c20e

Browse files
committed
fix(installer): dump gateway logs on startup timeout
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 0dee90a commit 6d7c20e

1 file changed

Lines changed: 62 additions & 2 deletions

File tree

install.sh

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,64 @@ start_user_gateway() {
603603
wait_for_local_gateway_status
604604
}
605605

606+
dump_local_gateway_diagnostics() {
607+
_lines="${OPENSHELL_INSTALL_LOG_LINES:-80}"
608+
case "$_lines" in
609+
"" | *[!0-9]*)
610+
_lines=80
611+
;;
612+
esac
613+
614+
info "dumping recent local gateway diagnostics..."
615+
case "${PLATFORM:-}" in
616+
darwin)
617+
dump_homebrew_gateway_diagnostics "$_lines"
618+
;;
619+
linux)
620+
dump_user_service_gateway_diagnostics "$_lines"
621+
;;
622+
*)
623+
info "no gateway log collector is available for platform: ${PLATFORM:-unknown}"
624+
;;
625+
esac
626+
}
627+
628+
dump_homebrew_gateway_diagnostics() {
629+
_lines="$1"
630+
_brew_prefix="$(as_target_user brew --prefix 2>/dev/null || true)"
631+
[ -n "$_brew_prefix" ] || _brew_prefix="/opt/homebrew"
632+
633+
info "Homebrew service status:"
634+
as_target_user brew services info "${HOMEBREW_TAP}/${HOMEBREW_FORMULA_NAME}" >&2 || true
635+
636+
for _log_file in \
637+
"${_brew_prefix}/var/log/openshell/openshell-gateway.err.log" \
638+
"${_brew_prefix}/var/log/openshell/openshell-gateway.out.log"; do
639+
if [ -f "$_log_file" ]; then
640+
info "last ${_lines} lines from ${_log_file}:"
641+
tail -n "$_lines" "$_log_file" >&2 || true
642+
else
643+
info "gateway log not found: ${_log_file}"
644+
fi
645+
done
646+
}
647+
648+
dump_user_service_gateway_diagnostics() {
649+
_lines="$1"
650+
651+
if has_cmd systemctl; then
652+
info "openshell-gateway user service status:"
653+
as_target_user systemctl --user status openshell-gateway --no-pager >&2 || true
654+
fi
655+
656+
if has_cmd journalctl; then
657+
info "last ${_lines} lines from openshell-gateway user journal:"
658+
as_target_user journalctl --user -u openshell-gateway --no-pager -n "$_lines" >&2 || true
659+
else
660+
info "journalctl not found; cannot dump openshell-gateway user journal"
661+
fi
662+
}
663+
606664
wait_for_local_gateway_listener() {
607665
_timeout="${OPENSHELL_INSTALL_GATEWAY_TIMEOUT:-30}"
608666
_elapsed=0
@@ -622,7 +680,8 @@ wait_for_local_gateway_listener() {
622680
_elapsed=$((_elapsed + 1))
623681
done
624682

625-
printf '%s\n' "$_last_output" >&2
683+
[ -z "$_last_output" ] || printf '%s\n' "$_last_output" >&2
684+
dump_local_gateway_diagnostics
626685
error "local gateway listener did not become reachable at ${_probe_url} within ${_timeout}s"
627686
}
628687

@@ -646,7 +705,8 @@ wait_for_local_gateway_status() {
646705
_elapsed=$((_elapsed + 1))
647706
done
648707

649-
printf '%s\n' "$_status_output" >&2
708+
[ -z "$_status_output" ] || printf '%s\n' "$_status_output" >&2
709+
dump_local_gateway_diagnostics
650710
error "openshell status did not report connected within ${_timeout}s"
651711
}
652712

0 commit comments

Comments
 (0)