Skip to content

Commit 3e170e4

Browse files
committed
Apply retry config and restore daemonize error handling
1 parent 2e94571 commit 3e170e4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

agent/internal/service/service.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ func (s *Service) Start() error {
106106

107107
// Handle daemon mode
108108
if s.config.Daemonize {
109-
s.daemonize()
109+
if err := s.daemonize(); err != nil {
110+
return fmt.Errorf("failed to daemonize: %w", err)
111+
}
110112
}
111113

112114
// Write PID file
@@ -437,21 +439,22 @@ func (s *Service) removePIDFile() {
437439
}
438440

439441
// daemonize runs the process in background (Unix-like systems)
440-
func (s *Service) daemonize() {
442+
func (s *Service) daemonize() error {
441443
if s == nil {
442-
return
444+
return fmt.Errorf("service is nil")
443445
}
444446
// This is a simplified daemonization
445447
// In production, you might want to use proper daemon libraries
446448
// or systemd service files
447449

448450
if os.Getppid() == defaultSignalCapacity {
449451
// Already daemonized
450-
return
452+
return nil
451453
}
452454

453455
// Fork and exit parent
454456
// Note: This is a basic implementation
455457
// For robust daemonization, consider using libraries like
456458
// github.com/sevlyar/go-daemon or systemd service files
459+
return nil
457460
}

services/authz/server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ func New(cfg Config) (*Server, error) {
144144
Multiplier: defaultRetryMultiplier,
145145
MaxInterval: defaultMaxInterval,
146146
}
147+
if cfg.RetryMaxAttempts > 0 {
148+
retryCfg.MaxAttempts = cfg.RetryMaxAttempts
149+
}
147150

148151
// Configure inventory client with optional mTLS
149152
invClient, err := configureInventoryClient(cfg)

0 commit comments

Comments
 (0)