示例#1
0
func (nc *nspawnCluster) systemdReload() error {
	conn, err := dbus.New()
	if err != nil {
		return err
	}
	conn.Reload()
	return nil
}
示例#2
0
func NewSystemdManager(machine *machine.Machine, unitPrefix string) *SystemdManager {
	systemd, err := dbus.New()
	if err != nil {
		panic(err)
	}

	return &SystemdManager{systemd, machine, unitPrefix, defaultSystemdRuntimePath, systemd.NewSubscriptionSet(), nil}
}
示例#3
0
文件: manager.go 项目: rswart/fleet
func NewSystemdManager(machine *machine.Machine) (*SystemdManager, error) {
	systemd, err := dbus.New()
	if err != nil {
		return nil, err
	}

	if err := os.MkdirAll(fleetUnitPath, os.FileMode(0755)); err != nil {
		return nil, err
	}

	return &SystemdManager{systemd, machine, systemd.NewSubscriptionSet(), nil}, nil
}
示例#4
0
文件: manager.go 项目: paulczar/fleet
func NewSystemdUnitManager(uDir string) (*SystemdUnitManager, error) {
	systemd, err := dbus.New()
	if err != nil {
		return nil, err
	}

	if err := os.MkdirAll(uDir, os.FileMode(0755)); err != nil {
		return nil, err
	}

	mgr := SystemdUnitManager{systemd, uDir, systemd.NewSubscriptionSet()}
	return &mgr, nil
}
示例#5
0
文件: manager.go 项目: jsdir/fleet
func NewSystemdManager(machine *machine.Machine, unitPrefix string) *SystemdManager {
	systemd, err := dbus.New()
	if err != nil {
		panic(err)
	}

	name := "fleet-" + machine.State().BootId + ".target"
	target := NewSystemdTarget(name)

	mgr := &SystemdManager{systemd, target, machine, unitPrefix, defaultSystemdRuntimePath, systemd.NewSubscriptionSet(), nil}
	mgr.writeUnit(target.Name(), "")

	return mgr
}
示例#6
0
func (nc *nspawnCluster) systemd(unitName, exec string) error {
	conn, err := dbus.New()
	if err != nil {
		return err
	}

	props := []dbus.Property{
		dbus.PropExecStart(strings.Split(exec, " "), false),
	}

	log.Printf("Creating transient systemd unit %s", unitName)

	if _, err = conn.StartTransientUnit(unitName, "replace", props...); err != nil {
		log.Printf("Failed creating transient unit %s: %v", unitName, err)
		return err
	}

	_, err = conn.StartUnit(unitName, "replace")
	if err != nil {
		log.Printf("Failed starting transient unit %s: %v", unitName, err)
	}

	return err
}