提交 87f2e380 作者: Steven Allen

systemd: add notify support

That way, we can reliably know when the daemon is ready.
上级 a4914a44
......@@ -411,10 +411,12 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
// The daemon is *finally* ready.
fmt.Printf("Daemon is ready\n")
notifyReady()
// Give the user some immediate feedback when they hit C-c
go func() {
<-req.Context.Done()
notifyStopping()
fmt.Println("Received interrupt signal, shutting down...")
fmt.Println("(Hit ctrl-c again to force-shutdown the daemon.)")
}()
......
// +build linux
package main
import (
daemon "github.com/coreos/go-systemd/daemon"
)
func notifyReady() {
_, _ = daemon.SdNotify(false, daemon.SdNotifyReady)
}
func notifyStopping() {
_, _ = daemon.SdNotify(false, daemon.SdNotifyStopping)
}
// +build !linux
package main
func notifyReady() {}
func notifyStopping() {}
......@@ -2,6 +2,7 @@
Description=IPFS Daemon
[Service]
Type=notify
ExecStart=/usr/bin/ipfs daemon --init --migrate
KillSignal=SIGINT
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论