@@ -79,12 +79,18 @@ func (c *client) initWithMasterSocket(opt options.RuntimeOptions) error {
7979
8080// GetStats returns stats from the socket
8181func (c * client ) GetStats () models.NativeStats {
82+ if ! c .runtime .IsValid () {
83+ return models.NativeStats {}
84+ }
8285 result := c .runtime .GetStats ()
8386 return result
8487}
8588
8689// GetInfo returns info from the socket
8790func (c * client ) GetInfo () (models.ProcessInfo , error ) {
91+ if ! c .runtime .IsValid () {
92+ return models.ProcessInfo {}, errors .New ("no valid runtime found" )
93+ }
8894 result := c .runtime .GetInfo ()
8995 return result , nil
9096}
@@ -104,6 +110,9 @@ func (c *client) GetVersion() (HAProxyVersion, error) {
104110 _ , err , _ = versionSfg .Do (versionKey , func () (interface {}, error ) {
105111 version := & HAProxyVersion {}
106112 var response string
113+ if ! c .runtime .IsValid () {
114+ return HAProxyVersion {}, errors .New ("no valid runtime found" )
115+ }
107116 response , err = c .runtime .ExecuteRaw ("show info" )
108117 if err != nil {
109118 return HAProxyVersion {}, err
@@ -155,6 +164,9 @@ func (c *client) Reload() (string, error) {
155164 return "" , fmt .Errorf ("cannot reload: requires HAProxy 2.7 or later but current version is %v" , haproxyVersion )
156165 }
157166
167+ if ! c .runtime .IsValid () {
168+ return "" , errors .New ("cannot reload: no valid runtime found" )
169+ }
158170 output , err := c .runtime .ExecuteMaster ("reload" )
159171 if err != nil {
160172 return "" , fmt .Errorf ("cannot reload: %w" , err )
0 commit comments