github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/util/sdnotify/sdnotify.go (about) 1 // Copyright 2017 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 // Package sdnotify implements both sides of the systemd readiness 12 // protocol. Servers can use sdnotify.Ready() to signal that they are 13 // ready to receive traffic, and process managers can use 14 // sdnotify.Exec() to run processes that implement this protocol. 15 package sdnotify 16 17 import "os/exec" 18 19 // Ready sends a readiness signal using the systemd notification 20 // protocol. It should be called (once) by a server after it has 21 // completed its initialization (including but not necessarily limited 22 // to binding ports) and is ready to receive traffic. 23 func Ready() error { 24 return ready() 25 } 26 27 // Exec the given command in the background using the systemd 28 // notification protocol. This function returns once the command has 29 // either exited or signaled that it is ready. If the command exits 30 // with a non-zero status before signaling readiness, returns an 31 // exec.ExitError. 32 func Exec(cmd *exec.Cmd) error { 33 return bgExec(cmd) 34 }