Documentation
¶
Overview ¶
Package agent is the viam-agent itself. It contains code to install/update the systemd service as well.
Package agent contains the public interfaces, functions, consts, and vars for the viam-server agent.
Index ¶
- Constants
- func Install(ctx context.Context, logger logging.Logger, sdManager systemdManager) error
- func InstallNewVersion(ctx context.Context, logger logging.Logger) (bool, error)
- func VersionCacheExists() bool
- type Manager
- func (m *Manager) CheckIfNeedsRestart(ctx context.Context) (time.Duration, bool)
- func (m *Manager) CheckUpdates(ctx context.Context) time.Duration
- func (m *Manager) CloseAll()
- func (m *Manager) CreateNetAppender() (*logging.NetAppender, error)
- func (m *Manager) Exit(reason string)
- func (m *Manager) GetConfig(ctx context.Context) (time.Duration, error)
- func (m *Manager) GetNetAppender() logging.Appender
- func (m *Manager) LoadAppConfig() error
- func (m *Manager) SelfUpdate(ctx context.Context) (bool, error)
- func (m *Manager) StartBackgroundChecks(ctx context.Context)
- func (m *Manager) StartSubsystem(ctx context.Context, name string) error
- func (m *Manager) SubsystemHealthChecks(ctx context.Context)
- func (m *Manager) SubsystemUpdates(ctx context.Context)
- type VersionCache
- func (c *VersionCache) AgentVersion() string
- func (c *VersionCache) CleanCache(ctx context.Context)
- func (c *VersionCache) CleanPartials(ctx context.Context) error
- func (c *VersionCache) MarkViamServerRunningVersion()
- func (c *VersionCache) Update(cfg *pb.UpdateInfo, binary string) error
- func (c *VersionCache) UpdateBinary(ctx context.Context, binary string) (bool, error)
- func (c *VersionCache) ViamServerRunningVersion() string
- func (c *VersionCache) ViamServerVersion() string
- type VersionInfo
- type Versions
Constants ¶
const (
SubsystemName = "viam-agent"
)
Variables ¶
This section is empty.
Functions ¶
func InstallNewVersion ¶ added in v0.14.0
InstallNewVersion runs the newly downloaded binary's Install() for installation of systemd files and the like.
func VersionCacheExists ¶ added in v0.22.2
func VersionCacheExists() bool
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the core of the agent process, and maintains the list of subsystems, as well as cloud connection.
func NewManager ¶
func NewManager(ctx context.Context, logger logging.Logger, cfg utils.AgentConfig, globalCancel context.CancelFunc) *Manager
NewManager returns a new Manager.
func (*Manager) CheckIfNeedsRestart ¶ added in v0.22.3
CheckIfNeedsRestart returns the check restart interval and whether the agent (and therefore all its subsystems) has been forcibly restarted by app.
func (*Manager) CheckUpdates ¶
CheckUpdates retrieves an updated config from the cloud, and then passes it to SubsystemUpdates().
func (*Manager) CloseAll ¶
func (m *Manager) CloseAll()
CloseAll stops all subsystems and closes the cloud connection.
func (*Manager) CreateNetAppender ¶ added in v0.4.0
func (m *Manager) CreateNetAppender() (*logging.NetAppender, error)
CreateNetAppender creates or replaces m.netAppender. Must be called after config is loaded.
func (*Manager) GetNetAppender ¶ added in v0.17.0
GetNetAppender is a somewhat ugly workaround to pass the (constructed later) netAppender to the syscfg subsystem.
func (*Manager) LoadAppConfig ¶ added in v0.14.0
func (*Manager) SelfUpdate ¶
SelfUpdate is called early in startup to update the viam-agent subsystem before any other work is started.
func (*Manager) StartBackgroundChecks ¶
StartBackgroundChecks kicks off go routines that loop on a timerr to check for updates, health checks, and restarts.
func (*Manager) StartSubsystem ¶ added in v0.1.0
StartSubsystem may be called early in startup when no cloud connectivity is configured.
func (*Manager) SubsystemHealthChecks ¶
SubsystemHealthChecks makes sure all subsystems are responding, and restarts them if not.
func (*Manager) SubsystemUpdates ¶
SubsystemUpdates checks for updates to configured subsystems and restarts them as needed.
type VersionCache ¶ added in v0.14.0
type VersionCache struct {
ViamAgent *Versions `json:"viam_agent"`
ViamServer *Versions `json:"viam_server"`
LastCleaned time.Time `json:"last_cleaned"`
// contains filtered or unexported fields
}
func NewVersionCache ¶ added in v0.14.0
func NewVersionCache(logger logging.Logger) *VersionCache
func (*VersionCache) AgentVersion ¶ added in v0.14.0
func (c *VersionCache) AgentVersion() string
func (*VersionCache) CleanCache ¶ added in v0.18.0
func (c *VersionCache) CleanCache(ctx context.Context)
func (*VersionCache) CleanPartials ¶ added in v0.23.0
func (c *VersionCache) CleanPartials(ctx context.Context) error
CleanPartials is called by CleanCache and cleans up incomplete partial downloads that have not been modified for 3 days. The 3-day grace period is 1) to avoid breaking ongoing downloads and 2) to give spotty connections a chance to resolve.
func (*VersionCache) MarkViamServerRunningVersion ¶ added in v0.14.0
func (c *VersionCache) MarkViamServerRunningVersion()
func (*VersionCache) Update ¶ added in v0.14.0
func (c *VersionCache) Update(cfg *pb.UpdateInfo, binary string) error
Update processes data for the two binaries: agent itself, and viam-server.
func (*VersionCache) UpdateBinary ¶ added in v0.14.0
UpdateBinary actually downloads and/or validates the targeted version. Returns true if a restart is needed.
func (*VersionCache) ViamServerRunningVersion ¶ added in v0.14.0
func (c *VersionCache) ViamServerRunningVersion() string
func (*VersionCache) ViamServerVersion ¶ added in v0.14.0
func (c *VersionCache) ViamServerVersion() string
type VersionInfo ¶
type VersionInfo struct {
Version string
URL string
DlPath string
DlSHA []byte
UnpackedPath string
// the sha256 field of the UpdateInfo proto
UnpackedSHA []byte
SymlinkPath string
Installed time.Time
// Last-Modified field from http header, if available
LastModified time.Time
LastModifiedCheck time.Time
}
VersionInfo records details about each version of a subsystem.
type Versions ¶ added in v0.14.0
type Versions struct {
TargetVersion string `json:"target_version"`
CurrentVersion string `json:"current_version"`
PreviousVersion string `json:"previous_version"`
Versions map[string]*VersionInfo `json:"versions"`
// contains filtered or unexported fields
}
Versions stores VersionInfo and the current/previous versions for (TODO) rollback.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
provisioning-client
command
|
|
|
test-client
command
A simple test client to fetch and print the results of DeviceAgentConfig() for use when testing changes in App.
|
A simple test client to fetch and print the results of DeviceAgentConfig() for use when testing changes in App. |
|
viam-agent
command
|
|
|
internal
|
|
|
serialcontrol
Package serialcontrol provides utilities to control a Linux machine, probably a Raspberry Pi running Rasbian, via a serial terminal.
|
Package serialcontrol provides utilities to control a Linux machine, probably a Raspberry Pi running Rasbian, via a serial terminal. |
|
subsystems
|
|
|
networking
Package networking is the subsystem responsible for network/wifi management, and initial device setup via hotspot.
|
Package networking is the subsystem responsible for network/wifi management, and initial device setup via hotspot. |
|
syscfg
Package syscfg contains the system configuration agent subsystem.
|
Package syscfg contains the system configuration agent subsystem. |
|
viamserver
Package viamserver contains the viam-server agent subsystem.
|
Package viamserver contains the viam-server agent subsystem. |
|
Package utils contains helper functions shared between the main agent and subsystems
|
Package utils contains helper functions shared between the main agent and subsystems |
|
systemd
Package systemd provides helpers to manipulate systemd services that are specifict to viam-agent's needs.
|
Package systemd provides helpers to manipulate systemd services that are specifict to viam-agent's needs. |