Add additional logging around resource polling
This commit is contained in:
parent
490f874128
commit
d99225c0fb
|
@ -61,7 +61,11 @@ func (e *Environment) Attach() error {
|
|||
// from being reached until it is completed if not run in a seperate process. However,
|
||||
// we still want it to be stopped when the copy operation below is finished running which
|
||||
// indicates that the container is no longer running.
|
||||
go e.pollResources(ctx)
|
||||
go func(ctx context.Context) {
|
||||
if err := e.pollResources(ctx); err != nil {
|
||||
log.WithField("environment_id", e.Id).WithField("error", errors.WithStack(err)).Error("error during environment resource polling")
|
||||
}
|
||||
}(ctx)
|
||||
|
||||
// Stream the reader output to the console which will then fire off events and handle console
|
||||
// throttling and sending the output to the user.
|
||||
|
|
|
@ -38,11 +38,14 @@ func (e *Environment) pollResources(ctx context.Context) error {
|
|||
log.WithField("container_id", e.Id).Warn("encountered error processing docker stats output, stopping collection")
|
||||
}
|
||||
|
||||
log.WithField("container_id", e.Id).Debug("detected io.EOF, stopping resource polling")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Disable collection if the server is in an offline state and this process is still running.
|
||||
if e.State() == environment.ProcessOfflineState {
|
||||
log.WithField("container_id", e.Id).Debug("process in offline state while resource polling is still active; stopping poll")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -66,8 +69,11 @@ func (e *Environment) pollResources(ctx context.Context) error {
|
|||
},
|
||||
}
|
||||
|
||||
b, _ := json.Marshal(st)
|
||||
e.Events().Publish(environment.ResourceEvent, string(b))
|
||||
if b, err := json.Marshal(st); err != nil {
|
||||
log.WithField("container_id", e.Id).WithField("error", errors.WithStack(err)).Warn("error while marshaling stats object for environment")
|
||||
} else {
|
||||
e.Events().Publish(environment.ResourceEvent, string(b))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func (h *Handler) ListenForExpiration(ctx context.Context) {
|
|||
if jwt != nil {
|
||||
if jwt.ExpirationTime.Unix()-time.Now().Unix() <= 0 {
|
||||
_ = h.SendJson(&Message{Event: TokenExpiredEvent})
|
||||
} else if jwt.ExpirationTime.Unix()-time.Now().Unix() <= 180 {
|
||||
} else if jwt.ExpirationTime.Unix()-time.Now().Unix() <= 60 {
|
||||
_ = h.SendJson(&Message{Event: TokenExpiringEvent})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user