mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-30 16:29:09 +01:00
Defines an API for knowing if the SERVICE is running (regardless of up and down state)
New() builds s.connecClient and is called when the gRPC service is started. Up() is invoked only IF a gRPC service IS running which is possible only if the New() was called.
This commit is contained in:
@@ -483,6 +483,18 @@ func (c *ConnectClient) IsRunning() bool {
|
||||
return c.sup.isRunning()
|
||||
}
|
||||
|
||||
// ServiceRunning reports whether the client's lifecycle supervisor is alive and
|
||||
// able to accept start/stop commands — i.e. the daemon-lifetime client exists
|
||||
// and its context has not been cancelled. It is independent of whether a run is
|
||||
// currently up (that is IsRunning). Nil-safe, so callers can ask it on a
|
||||
// not-yet-constructed client and treat false as "service not running".
|
||||
func (c *ConnectClient) ServiceRunning() bool {
|
||||
if c == nil || c.sup == nil {
|
||||
return false
|
||||
}
|
||||
return c.sup.ctx.Err() == nil
|
||||
}
|
||||
|
||||
func (c *ConnectClient) Engine() *Engine {
|
||||
if c == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user