mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-27 02:37:38 +00:00
util/systemd: don't log warnings when not running under systemd
It caused our integration tests to fail, which prohibit logging to os.Stderr for test cleanliness reasons.
This commit is contained in:
parent
741c513e51
commit
5f07da4854
@ -8,6 +8,7 @@ package systemd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/mdlayher/sdnotify"
|
"github.com/mdlayher/sdnotify"
|
||||||
@ -35,8 +36,13 @@ var (
|
|||||||
|
|
||||||
func notifier() *sdnotify.Notifier {
|
func notifier() *sdnotify.Notifier {
|
||||||
getNotifyOnce.Do(func() {
|
getNotifyOnce.Do(func() {
|
||||||
|
sock := os.Getenv(sdnotify.Socket)
|
||||||
|
if sock == "" {
|
||||||
|
// Not running under systemd probably. Bail out before logging.
|
||||||
|
return
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
getNotifyOnce.v, err = sdnotify.New()
|
getNotifyOnce.v, err = sdnotify.Open(sock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("systemd: systemd-notifier error: %v", err)
|
log.Printf("systemd: systemd-notifier error: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user