mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
start corrosion service even when machine is not initialised to be able to init cluster
This commit is contained in:
@@ -2,4 +2,6 @@ package corroservice
|
||||
|
||||
type Service interface {
|
||||
Start() error
|
||||
Restart() error
|
||||
Running() bool
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ const DefaultSystemdUnit = "uncloud-corrosion.service"
|
||||
type SystemdService struct {
|
||||
DataDir string
|
||||
Unit string
|
||||
running bool
|
||||
}
|
||||
|
||||
func DefaultSystemdService(dataDir string) *SystemdService {
|
||||
@@ -25,5 +26,23 @@ func (s *SystemdService) Start() error {
|
||||
return fmt.Errorf("systemctl start %s: %w", s.Unit, err)
|
||||
}
|
||||
slog.Info("Corrosion systemd service started.", "unit", s.Unit)
|
||||
|
||||
// TODO: run a goroutine to check the status of the service and log any errors in the uncloud log.
|
||||
s.running = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SystemdService) Restart() error {
|
||||
if _, err := exec.Command("systemctl", "restart", s.Unit).Output(); err != nil {
|
||||
return fmt.Errorf("systemctl restart %s: %w", s.Unit, err)
|
||||
}
|
||||
slog.Info("Corrosion systemd service restarted.", "unit", s.Unit)
|
||||
|
||||
// TODO: run a goroutine to check the status of the service and log any errors in the uncloud log.
|
||||
s.running = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SystemdService) Running() bool {
|
||||
return s.running
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user