Add activity tracker server, Hyprland agent and Gitea image publishing
The Go API on PostgreSQL ingests desktop, browser, presence, manual and Health Auto Export events and serves activities and daily goal summaries. The Hyprland agent records window focus, idle and lock intervals. The CI workflow publishes adam-french.co.uk/adamf/activity-tracker to the Gitea registry and rolls the web_server stack onto it. The image probes itself through a new `tracker healthcheck` command, because distroless has no wget. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// Package config loads server configuration from environment variables.
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
DatabaseURL string
|
||||
ListenAddr string
|
||||
AutoMigrate bool
|
||||
Location *time.Location // timezone used for day boundaries in summaries
|
||||
}
|
||||
|
||||
func Load() (Config, error) {
|
||||
c := Config{
|
||||
DatabaseURL: os.Getenv("DATABASE_URL"),
|
||||
ListenAddr: envOr("LISTEN_ADDR", ":8080"),
|
||||
}
|
||||
if c.DatabaseURL == "" {
|
||||
return c, errors.New("DATABASE_URL is required")
|
||||
}
|
||||
|
||||
var err error
|
||||
if c.AutoMigrate, err = strconv.ParseBool(envOr("AUTO_MIGRATE", "true")); err != nil {
|
||||
return c, fmt.Errorf("AUTO_MIGRATE: %w", err)
|
||||
}
|
||||
if c.Location, err = time.LoadLocation(envOr("TRACKER_TZ", "UTC")); err != nil {
|
||||
return c, fmt.Errorf("TRACKER_TZ: %w", err)
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func envOr(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
Reference in New Issue
Block a user