From 7def391da57af6a44078d88829e022c4531a399b Mon Sep 17 00:00:00 2001 From: Ale Paredes <1709578+ale7714@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:07:30 -0400 Subject: [PATCH] Favor starting viam-server first (#17) --- cmd/viam-agent/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/viam-agent/main.go b/cmd/viam-agent/main.go index cc754e6..c877b12 100644 --- a/cmd/viam-agent/main.go +++ b/cmd/viam-agent/main.go @@ -170,16 +170,16 @@ func main() { } } - // Check for self-update and restart if needed. - needRestart, err := manager.SelfUpdate(ctx) - if err != nil { - globalLogger.Error(err) - } - if needRestart { - globalLogger.Info("updated self, exiting to await restart with new version") - return + // Start viam server as soon as possible. Then, start other subsystems and check for updates + if err := manager.StartSubsystem(ctx, viamserver.SubsysName); err != nil { + if errors.Is(err, agent.ErrSubsystemDisabled) { + globalLogger.Warn("viam-server subsystem disabled, please manually update /etc/viam.json and connect to internet") + } else { + globalLogger.Errorf("could not start viam-server subsystem: %s", err) + } } + globalLogger.Debug("==== Starting background checks =====") manager.StartBackgroundChecks(ctx) <-ctx.Done()