File tree 3 files changed +55
-5
lines changed
3 files changed +55
-5
lines changed Original file line number Diff line number Diff line change
1
+ var path = require ( "path" ) ,
2
+ spawn = require ( "child_process" ) . spawn ;
3
+
4
+ function Process ( script ) {
5
+ this . args = [ ] . slice . call ( arguments ) ;
6
+ this . args [ 0 ] = path . join ( __dirname , script ) ;
7
+ this . start ( ) ;
8
+ Process . list . push ( this ) ;
9
+ }
10
+
11
+ Process . list = [ ] ;
12
+
13
+ Process . prototype . respawn = true ;
14
+
15
+ Process . prototype . start = function ( ) {
16
+ this . child = spawn ( "node" , this . args ) ;
17
+ this . child . on ( "exit" , this . onExit . bind ( this ) ) ;
18
+ } ;
19
+
20
+ Process . prototype . onExit = function ( code ) {
21
+ if ( code !== 0 && this . respawn ) {
22
+ this . start ( ) ;
23
+ }
24
+ } ;
25
+
26
+ new Process ( "update-server.js" , "--console" ) ;
27
+ new Process ( "wordpress-update.js" , "--console" ) ;
28
+ new Process ( "retry.js" , "--console" ) ;
29
+
30
+ // Let SIGINT pass through to spawned processes. When all children exit,
31
+ // the manager will end on its own.
32
+ process . on ( "SIGINT" , function ( ) {
33
+ Process . list . forEach ( function ( process ) {
34
+ process . respawn = false ;
35
+ } ) ;
36
+ } ) ;
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ actions.processMeta = function( repoId, fn ) {
36
36
hook . processMeta ( repo , fn ) ;
37
37
} ;
38
38
39
- function processFailures ( fn ) {
39
+ var processFailures = function ( fn ) {
40
40
Step (
41
41
function ( ) {
42
42
retry . getFailure ( this ) ;
@@ -74,14 +74,21 @@ function processFailures( fn ) {
74
74
75
75
function ( error ) {
76
76
if ( error ) {
77
- console . log ( error . stack ) ;
77
+ return fn ( error ) ;
78
78
}
79
79
80
80
processFailures ( fn ) ;
81
81
}
82
82
) ;
83
- }
83
+ } ;
84
84
85
85
processFailures ( function ( error ) {
86
86
logger . error ( "Error during retry: " + error . stack ) ;
87
87
} ) ;
88
+
89
+ // Let the current retry finish, then stop processing and exit
90
+ process . on ( "SIGINT" , function ( ) {
91
+ processFailures = function ( fn ) {
92
+ fn ( null ) ;
93
+ } ;
94
+ } ) ;
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ function processActions( fn ) {
199
199
) ;
200
200
}
201
201
202
- function processActionsSince ( actionId , fn ) {
202
+ var processActionsSince = function ( actionId , fn ) {
203
203
Step (
204
204
function ( ) {
205
205
processNextAction ( actionId , this ) ;
@@ -230,7 +230,7 @@ function processActionsSince( actionId, fn ) {
230
230
processActionsSince ( action . id , fn ) ;
231
231
}
232
232
) ;
233
- }
233
+ } ;
234
234
235
235
function processNextAction ( actionId , fn ) {
236
236
Step (
@@ -268,3 +268,10 @@ function processNextAction( actionId, fn ) {
268
268
processActions ( function ( error ) {
269
269
logger . error ( "Error updating WordPress: " + error . stack ) ;
270
270
} ) ;
271
+
272
+ // Let the current action finish, then stop processing and exit
273
+ process . on ( "SIGINT" , function ( ) {
274
+ processActionsSince = function ( actionId , fn ) {
275
+ fn ( null ) ;
276
+ } ;
277
+ } ) ;
You can’t perform that action at this time.
0 commit comments