mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-27 11:33:33 +00:00
39 lines
657 B
Go
39 lines
657 B
Go
package machine
|
|
|
|
import (
|
|
"fmt"
|
|
"log/slog"
|
|
"os/exec"
|
|
)
|
|
|
|
const (
|
|
CorrosionSystemdUnit = "uncloud-corrosion.service"
|
|
)
|
|
|
|
type CorrosionService interface {
|
|
Configure() error
|
|
Start() error
|
|
}
|
|
|
|
type CorrosionSystemdService struct {
|
|
Unit string
|
|
DataDir string
|
|
}
|
|
|
|
func (s *CorrosionSystemdService) Configure() error {
|
|
return nil
|
|
}
|
|
|
|
func (s *CorrosionSystemdService) Start() error {
|
|
unit := s.Unit
|
|
if unit == "" {
|
|
unit = CorrosionSystemdUnit
|
|
}
|
|
|
|
if _, err := exec.Command("systemctl", "start", unit).Output(); err != nil {
|
|
return fmt.Errorf("start %s: %w", unit, err)
|
|
}
|
|
slog.Info("Corrosion systemd service started.", "unit", unit)
|
|
return nil
|
|
}
|