| 1 | Copyright © 2022 Oleg Pykhalov <[email protected]>
|
| 2 |
|
| 3 | Create a PID file after containerd is ready to serve requests.
|
| 4 |
|
| 5 | Fixes <https://issues.guix.gnu.org/38432>.
|
| 6 |
|
| 7 | |
| 8 | |
| 9 | @@ -22,15 +22,22 @@
|
| 10 | sd "github.com/coreos/go-systemd/v22/daemon"
|
| 11 |
|
| 12 | "github.com/containerd/containerd/log"
|
| 13 | +
|
| 14 | + "os"
|
| 15 | + "strconv"
|
| 16 | )
|
| 17 |
|
| 18 | // notifyReady notifies systemd that the daemon is ready to serve requests
|
| 19 | func notifyReady(ctx context.Context) error {
|
| 20 | + pidFile, _ := os.Create("/run/containerd/containerd.pid")
|
| 21 | + defer pidFile.Close()
|
| 22 | + pidFile.WriteString(strconv.FormatInt(int64(os.Getpid()), 10))
|
| 23 | return sdNotify(ctx, sd.SdNotifyReady)
|
| 24 | }
|
| 25 |
|
| 26 | // notifyStopping notifies systemd that the daemon is about to be stopped
|
| 27 | func notifyStopping(ctx context.Context) error {
|
| 28 | + os.Remove("/run/containerd/containerd.pid")
|
| 29 | return sdNotify(ctx, sd.SdNotifyStopping)
|
| 30 | }
|
| 31 |
|