[#1135] sdnotify: Send MONOTONIC_USEC on reload
All checks were successful
Tests and linters / Lint (pull_request) Successful in 8m35s
DCO action / DCO (pull_request) Successful in 13m29s
Vulncheck / Vulncheck (pull_request) Successful in 14m3s
Build / Build Components (1.22) (pull_request) Successful in 15m41s
Build / Build Components (1.21) (pull_request) Successful in 16m53s
Tests and linters / gopls check (pull_request) Successful in 17m3s
Pre-commit hooks / Pre-commit (pull_request) Successful in 17m35s
Tests and linters / Staticcheck (pull_request) Successful in 18m43s
Tests and linters / Tests (1.22) (pull_request) Successful in 18m54s
Tests and linters / Tests (1.21) (pull_request) Successful in 3m2s
Tests and linters / Tests with -race (pull_request) Successful in 5m45s
All checks were successful
Tests and linters / Lint (pull_request) Successful in 8m35s
DCO action / DCO (pull_request) Successful in 13m29s
Vulncheck / Vulncheck (pull_request) Successful in 14m3s
Build / Build Components (1.22) (pull_request) Successful in 15m41s
Build / Build Components (1.21) (pull_request) Successful in 16m53s
Tests and linters / gopls check (pull_request) Successful in 17m3s
Pre-commit hooks / Pre-commit (pull_request) Successful in 17m35s
Tests and linters / Staticcheck (pull_request) Successful in 18m43s
Tests and linters / Tests (1.22) (pull_request) Successful in 18m54s
Tests and linters / Tests (1.21) (pull_request) Successful in 3m2s
Tests and linters / Tests with -race (pull_request) Successful in 5m45s
Fixes #1135 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
b4cfc80579
commit
85527d0ce6
3 changed files with 27 additions and 0 deletions
10
pkg/util/sdnotify/clock.go
Normal file
10
pkg/util/sdnotify/clock.go
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package sdnotify
|
||||||
|
|
||||||
|
import (
|
||||||
|
// For go:linkname to work.
|
||||||
|
_ "unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:noescape
|
||||||
|
//go:linkname nanotime runtime.nanotime
|
||||||
|
func nanotime() int64
|
2
pkg/util/sdnotify/clock.s
Normal file
2
pkg/util/sdnotify/clock.s
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
// The file is intentionally empty.
|
||||||
|
// It is a workaround for https://github.com/golang/go/issues/15006
|
|
@ -38,6 +38,21 @@ func InitSocket() error {
|
||||||
// FlagAndStatus sends systemd a combination of a
|
// FlagAndStatus sends systemd a combination of a
|
||||||
// well-known status and STATUS=%s{status}, separated by newline.
|
// well-known status and STATUS=%s{status}, separated by newline.
|
||||||
func FlagAndStatus(status string) error {
|
func FlagAndStatus(status string) error {
|
||||||
|
if status == ReloadingEnabled {
|
||||||
|
// From https://www.man7.org/linux/man-pages/man5/systemd.service.5.html
|
||||||
|
//
|
||||||
|
// When initiating the reload process the service is
|
||||||
|
// expected to reply with a notification message via
|
||||||
|
// sd_notify(3) that contains the "RELOADING=1" field in
|
||||||
|
// combination with "MONOTONIC_USEC=" set to the current
|
||||||
|
// monotonic time (i.e. CLOCK_MONOTONIC in
|
||||||
|
// clock_gettime(2)) in μs, formatted as decimal string.
|
||||||
|
// Once reloading is complete another notification message
|
||||||
|
// must be sent, containing "READY=1".
|
||||||
|
//
|
||||||
|
// For MONOTONIC_USEC format refer to https://www.man7.org/linux/man-pages/man3/sd_notify.3.html
|
||||||
|
status += fmt.Sprintf("\nMONOTONIC_USEC=%d", uint64(nanotime())/1e3 /* microseconds in nanoseconds */)
|
||||||
|
}
|
||||||
status += "\nSTATUS=" + strings.TrimSuffix(status, "=1")
|
status += "\nSTATUS=" + strings.TrimSuffix(status, "=1")
|
||||||
return Send(status)
|
return Send(status)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue