Skip to content

Commit

Permalink
Allow execution to restart on IIP changes unless network was explicit…
Browse files Browse the repository at this point in the history
…ly stopped
  • Loading branch information
bergie committed Jul 20, 2017
1 parent 41d1eba commit 5e99b5f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/lib/Network.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Network extends EventEmitter
@defaults = []
@graph = graph
@started = false
@stopped = true
@debug = true
@eventBuffer = []

Expand Down Expand Up @@ -520,7 +521,14 @@ class Network extends EventEmitter
@initials.push init
@nextInitials.push init

do @sendInitials if @isStarted()
if @isRunning()
# Network is running now, send initials immediately
do @sendInitials
else if not @isStopped()
# Network has finished but hasn't been stopped, set
# started and set
@setStarted true
do @sendInitials

callback()

Expand Down Expand Up @@ -563,6 +571,8 @@ class Network extends EventEmitter

isStarted: ->
@started
isStopped: ->
@stopped

isRunning: ->
return false unless @started
Expand Down Expand Up @@ -657,9 +667,11 @@ class Network extends EventEmitter
count++
if count is length
@setStarted false
@stopped = true
callback()
unless @processes and Object.keys(@processes).length
@setStarted false
@stopped = true
return callback()
# Tell processes to shut down
for id, process of @processes
Expand Down Expand Up @@ -687,6 +699,7 @@ class Network extends EventEmitter
# Starting the execution
@startupDate = new Date unless @startupDate
@started = true
@stopped = false
@bufferedEmit 'start',
start: @startupDate

Expand Down

0 comments on commit 5e99b5f

Please sign in to comment.