Compare commits

...

4 Commits

Author SHA1 Message Date
henrygd
3b9910351d release 0.10.1 2025-03-06 05:40:38 -05:00
henrygd
f397ab0797 fix: improve error logging for temperature sensor retrieval 2025-03-06 05:38:49 -05:00
henrygd
b1fc715ec9 fix: prevent 404 on initial startup by moving h.initialize after hooks
- I don't know why this works. Need to look further into it tomorrow :)
2025-03-06 05:38:33 -05:00
henrygd
d25c7c58c1 fix: SYS_SENSORS context error (#643) 2025-03-06 05:36:20 -05:00
4 changed files with 11 additions and 12 deletions

View File

@@ -33,8 +33,9 @@ type Agent struct {
func NewAgent() *Agent { func NewAgent() *Agent {
agent := &Agent{ agent := &Agent{
fsStats: make(map[string]*system.FsStats), sensorsContext: context.Background(),
cache: NewSessionCache(69 * time.Second), fsStats: make(map[string]*system.FsStats),
cache: NewSessionCache(69 * time.Second),
} }
agent.memCalc, _ = GetEnv("MEM_CALC") agent.memCalc, _ = GetEnv("MEM_CALC")
@@ -59,8 +60,6 @@ func NewAgent() *Agent {
agent.sensorsContext = context.WithValue(agent.sensorsContext, agent.sensorsContext = context.WithValue(agent.sensorsContext,
common.EnvKey, common.EnvMap{common.HostSysEnvKey: sysSensors}, common.EnvKey, common.EnvMap{common.HostSysEnvKey: sysSensors},
) )
} else {
agent.sensorsContext = context.Background()
} }
// Set sensors whitelist // Set sensors whitelist

View File

@@ -187,7 +187,7 @@ func (a *Agent) getSystemStats() system.Stats {
// temperatures (skip if sensors whitelist is set to empty string) // temperatures (skip if sensors whitelist is set to empty string)
err = a.updateTemperatures(&systemStats) err = a.updateTemperatures(&systemStats)
if err != nil { if err != nil {
slog.Error("Error getting temperatures", "err", err) slog.Error("Error getting temperatures", "err", fmt.Sprintf("%+v", err))
} }
// GPU data // GPU data
@@ -238,6 +238,7 @@ func (a *Agent) updateTemperatures(systemStats *system.Stats) error {
// get sensor data // get sensor data
temps, err := sensors.TemperaturesWithContext(a.sensorsContext) temps, err := sensors.TemperaturesWithContext(a.sensorsContext)
if err != nil { if err != nil {
slog.Error("Error getting temperatures", "err", fmt.Sprintf("%+v", err))
return err return err
} }
slog.Debug("Temperature", "sensors", temps) slog.Debug("Temperature", "sensors", temps)

View File

@@ -64,11 +64,6 @@ func (h *Hub) BootstrapHub() (*Hub, error) {
} }
} }
// initial setup
if err := h.initialize(); err != nil {
return nil, err
}
// serve web ui // serve web ui
h.OnServe().BindFunc(h.startServer) h.OnServe().BindFunc(h.startServer)
// set up scheduled jobs // set up scheduled jobs
@@ -85,6 +80,11 @@ func (h *Hub) BootstrapHub() (*Hub, error) {
// start system updates // start system updates
h.sm.Initialize() h.sm.Initialize()
// initial setup
if err := h.initialize(); err != nil {
return nil, err
}
return h, nil return h, nil
} }
@@ -145,7 +145,6 @@ func (h *Hub) initialize() error {
// Start starts the hub application / server // Start starts the hub application / server
func (h *Hub) Start() error { func (h *Hub) Start() error {
// Use type assertion to access the Start method
if pb, ok := h.App.(*pocketbase.PocketBase); ok { if pb, ok := h.App.(*pocketbase.PocketBase); ok {
return pb.Start() return pb.Start()
} }

View File

@@ -1,6 +1,6 @@
package beszel package beszel
const ( const (
Version = "0.10.0" Version = "0.10.1"
AppName = "beszel" AppName = "beszel"
) )