mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-10-05 18:03:21 +08:00
Periodic tasks refactor (#62)
* Once every second the session run a list of periodic tasks on every instance concurrently. We use these tasks to do things like: - Collect mem and cpu stats - Check if instance is part of a swarm cluster - Broadcast information to connected clients
This commit is contained in:
committed by
GitHub
parent
07fee4c1bf
commit
afa47c0bfc
15
services/check_swarm_status_task.go
Normal file
15
services/check_swarm_status_task.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package services
|
||||
|
||||
import "github.com/docker/docker/api/types/swarm"
|
||||
|
||||
type checkSwarmStatusTask struct {
|
||||
}
|
||||
|
||||
func (c checkSwarmStatusTask) Run(i *Instance) {
|
||||
if info, err := GetDaemonInfo(i); err == nil {
|
||||
if info.Swarm.LocalNodeState != swarm.LocalNodeStateInactive && info.Swarm.LocalNodeState != swarm.LocalNodeStateLocked {
|
||||
i.IsManager = &info.Swarm.ControlAvailable
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user