重启单元文件时模式和通道应该是什么
What should be the mode and channel while restarting unit files
在go-systemd中,重启设备的第二个和第三个参数应该是什么。
// RestartUnit restarts a service. If a service is restarted that isn't
// running it will be started.
func (c *Conn) RestartUnit(name string, mode string, ch chan<- string) (int, error) {
return c.startJob(ch, "org.freedesktop.systemd1.Manager.RestartUnit", name, mode)
}
来自 PR 203, you can see that method used/tested 作为:
// Restart the unit
reschan = make(chan string)
_, err = conn.RestartUnit(target, "replace", reschan)
if err != nil {
t.Fatal(err)
}
job = <-reschan
if job != "done" {
t.Fatal("Job is not done:", job)
}
所以你必须创建自己的标签和频道。
// Takes the unit to activate, plus a **mode string**.
The mode needs to be one of:
- replace (the call will start the unit and its dependencies, possibly replacing already queued jobs that conflict with this),
- fail (the call will start the unit and its dependencies, but will fail if this would change an already queued job),
- isolate (the call will start the unit in question and terminate all units that aren't dependencies of it),
- ignore-dependencies (it will start a unit but ignore all its dependencies),
- ignore-requirements (it will start a unit but only ignore the requirement dependencies).
It is not recommended to make use of the latter two options.
在go-systemd中,重启设备的第二个和第三个参数应该是什么。
// RestartUnit restarts a service. If a service is restarted that isn't
// running it will be started.
func (c *Conn) RestartUnit(name string, mode string, ch chan<- string) (int, error) {
return c.startJob(ch, "org.freedesktop.systemd1.Manager.RestartUnit", name, mode)
}
来自 PR 203, you can see that method used/tested 作为:
// Restart the unit
reschan = make(chan string)
_, err = conn.RestartUnit(target, "replace", reschan)
if err != nil {
t.Fatal(err)
}
job = <-reschan
if job != "done" {
t.Fatal("Job is not done:", job)
}
所以你必须创建自己的标签和频道。
// Takes the unit to activate, plus a **mode string**.
The mode needs to be one of:
- replace (the call will start the unit and its dependencies, possibly replacing already queued jobs that conflict with this),
- fail (the call will start the unit and its dependencies, but will fail if this would change an already queued job),
- isolate (the call will start the unit in question and terminate all units that aren't dependencies of it),
- ignore-dependencies (it will start a unit but ignore all its dependencies),
- ignore-requirements (it will start a unit but only ignore the requirement dependencies).
It is not recommended to make use of the latter two options.