dream752614590 2017-12-11 05:36
浏览 102
已采纳

重新启动单元文件时,模式和通道应该是什么

In go-systemd, what should be the second and third parameters for restarting the units.

// 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)
}
  • 写回答

1条回答 默认 最新

  • dongyao5843 2017-12-11 05:44
    关注

    From PR 203, you can see that method used/tested as:

    // 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)
    }
    

    So you have to create your own label and channel.

    From dbus/methods.go

    // 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿