Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Oct 6, 2015
2 parents 257be30 + 930921d commit bfbdd19
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions client/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type AllocRunner struct {
destroy bool
destroyCh chan struct{}
destroyLock sync.Mutex
waitCh chan struct{}
}

// allocRunnerState is used to snapshot the state of the alloc runner
Expand All @@ -74,6 +75,7 @@ func NewAllocRunner(logger *log.Logger, config *config.Config, updater AllocStat
taskStatus: make(map[string]taskStatus),
updateCh: make(chan *structs.Allocation, 8),
destroyCh: make(chan struct{}),
waitCh: make(chan struct{}),
}
return ar
}
Expand Down Expand Up @@ -258,6 +260,7 @@ func (r *AllocRunner) setTaskStatus(taskName, status, desc string) {

// Run is a long running goroutine used to manage an allocation
func (r *AllocRunner) Run() {
defer close(r.waitCh)
go r.dirtySyncState()

// Check if the allocation is in a terminal status
Expand Down Expand Up @@ -376,3 +379,8 @@ func (r *AllocRunner) Destroy() {
r.destroy = true
close(r.destroyCh)
}

// WaitCh returns a channel to wait for termination
func (r *AllocRunner) WaitCh() <-chan struct{} {
return r.waitCh
}
9 changes: 9 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ func (c *Client) Shutdown() error {
if c.shutdown {
return nil
}

// Destroy all the running allocations.
if c.config.DevMode {
for _, ar := range c.allocs {
ar.Destroy()
<-ar.WaitCh()
}
}

c.shutdown = true
close(c.shutdownCh)
c.connPool.Shutdown()
Expand Down
2 changes: 1 addition & 1 deletion command/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ job "example" {
memory = 256 # 256MB
network {
mbits = 10
dynamic_ports = ["redis"]
dynamic_ports = ["6379"]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion website/source/layouts/_footer.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-62364009-1', 'auto');
ga('create', 'UA-68490725-1', 'auto');
ga('send', 'pageview');
</script>

Expand Down

0 comments on commit bfbdd19

Please sign in to comment.