Stream logs from syslog
This commit is contained in:
parent
02b93a3ef0
commit
f4481bca62
5 changed files with 287 additions and 5 deletions
|
|
@ -15,16 +15,18 @@ import (
|
|||
"github.com/nemunaire/repeater/internal/hotspot"
|
||||
"github.com/nemunaire/repeater/internal/logging"
|
||||
"github.com/nemunaire/repeater/internal/models"
|
||||
"github.com/nemunaire/repeater/internal/syslog"
|
||||
"github.com/nemunaire/repeater/internal/wifi"
|
||||
)
|
||||
|
||||
// App represents the application
|
||||
type App struct {
|
||||
Status models.SystemStatus
|
||||
StatusMutex sync.RWMutex
|
||||
StartTime time.Time
|
||||
Assets embed.FS
|
||||
Config *config.Config
|
||||
Status models.SystemStatus
|
||||
StatusMutex sync.RWMutex
|
||||
StartTime time.Time
|
||||
Assets embed.FS
|
||||
Config *config.Config
|
||||
SyslogTailer *syslog.SyslogTailer
|
||||
}
|
||||
|
||||
// New creates a new application instance
|
||||
|
|
@ -60,6 +62,19 @@ func (a *App) Initialize(cfg *config.Config) error {
|
|||
// Don't fail - polling fallback still works
|
||||
}
|
||||
|
||||
// Start syslog tailing if enabled
|
||||
if cfg.SyslogEnabled {
|
||||
a.SyslogTailer = syslog.NewSyslogTailer(
|
||||
cfg.SyslogPath,
|
||||
cfg.SyslogFilter,
|
||||
cfg.SyslogSource,
|
||||
)
|
||||
if err := a.SyslogTailer.Start(); err != nil {
|
||||
log.Printf("Warning: Failed to start syslog tailing: %v", err)
|
||||
// Don't fail - app continues without syslog
|
||||
}
|
||||
}
|
||||
|
||||
// Start periodic tasks
|
||||
go a.periodicStatusUpdate()
|
||||
go a.periodicDeviceUpdate()
|
||||
|
|
@ -78,6 +93,11 @@ func (a *App) Run(addr string) error {
|
|||
|
||||
// Shutdown gracefully shuts down the application
|
||||
func (a *App) Shutdown() {
|
||||
// Stop syslog tailing if running
|
||||
if a.SyslogTailer != nil {
|
||||
a.SyslogTailer.Stop()
|
||||
}
|
||||
|
||||
wifi.StopEventMonitoring()
|
||||
wifi.Close()
|
||||
logging.AddLog("Système", "Application arrêtée")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue