Skip to content

Commit

Permalink
Paralize bridge creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefaille committed Sep 3, 2015
1 parent a75f1ed commit 569ac3a
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"sync"

"github.com/mikefaille/docker-group-daemonizer/dockerGrp"
"github.com/mikefaille/docker-group-daemonizer/unixGrp"
"github.com/mikefaille/tenus"
Expand All @@ -12,31 +14,36 @@ type error interface {

func main() {

var wg sync.WaitGroup
wg.Add(1)
chanGroup := unixGrp.TakeAllGroups()

for currentG := range chanGroup {

gDocker, err := dockerGrp.CatchDockerEqGroup(currentG)

if err == nil {

gDocker.GenerateDockerDaemon()

if ok, err := tenus.IsInterfaceExist(gDocker.Name); !ok || err != nil {
check(err)
gDocker.AddNewDockerBr()

} else {
err := tenus.DelBridgeWithName(gDocker.Name)

check(err)
gDocker.AddNewDockerBr()
}

wg.Add(1)
go func() {
gDocker.GenerateDockerDaemon()

if ok, err := tenus.IsInterfaceExist(gDocker.Name); !ok || err != nil {
check(err)
gDocker.AddNewDockerBr()

} else {
err := tenus.DelBridgeWithName(gDocker.Name)

check(err)
gDocker.AddNewDockerBr()
}
wg.Done()
}()
}

}

wg.Done()
wg.Wait()
}

func check(e error) {
Expand Down

0 comments on commit 569ac3a

Please sign in to comment.