mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 03:53:33 +00:00
create corrosion config
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package corrosion
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
const DefaultSystemdUnit = "uncloud-corrosion.service"
|
||||
|
||||
type SystemdService struct {
|
||||
DataDir string
|
||||
Unit string
|
||||
User string
|
||||
}
|
||||
|
||||
func DefaultSystemdService(dataDir string) *SystemdService {
|
||||
return &SystemdService{
|
||||
DataDir: dataDir,
|
||||
Unit: DefaultSystemdUnit,
|
||||
User: DefaultUser,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SystemdService) Configure() error {
|
||||
// TODO: create config.toml and schema dir in DataDir.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SystemdService) Start() error {
|
||||
if _, err := exec.Command("systemctl", "start", s.Unit).Output(); err != nil {
|
||||
return fmt.Errorf("systemctl start %s: %w", s.Unit, err)
|
||||
}
|
||||
slog.Info("Corrosion systemd service started.", "unit", s.Unit)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user