File tree 1 file changed +42
-0
lines changed 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ $ queueF = __DIR__ .'/queue ' ;
4
+ $ queue = json_decode (file_exists ($ queueF ) ? file_get_contents ($ queueF ) : '[] ' , true );
5
+
6
+ if ($ argv [1 ] === 'run ' ) {
7
+ $ pids = [];
8
+ $ idx = 0 ;
9
+ foreach ($ queue as [$ cwd , $ cmd ]) {
10
+ $ cmdStr = implode (" " , $ cmd );
11
+ $ p = proc_open ($ cmd , [
12
+ ["pipe " , "r " ],
13
+ ["file " , sys_get_temp_dir ()."/out_ $ idx.txt " , "a " ],
14
+ ["file " , sys_get_temp_dir ()."/out_ $ idx.txt " , "a " ]
15
+ ], $ pipes , $ cwd );
16
+ if ($ p === false ) {
17
+ echo "Failure starting $ cmdStr " .PHP_EOL ;
18
+ exit (1 );
19
+ }
20
+ $ pids [$ cmdStr ] = [$ p , $ idx , $ cwd ];
21
+ $ idx ++;
22
+ }
23
+
24
+ $ final = 0 ;
25
+ foreach ($ pids as $ cmd => [$ p , $ idx , $ cwd ]) {
26
+ $ status = proc_close ($ p );
27
+ if ($ status > 128 ) {
28
+ $ final = $ status ;
29
+ echo "$ cwd: $ cmd terminated with status $ status " .PHP_EOL ;
30
+ chdir ($ cwd );
31
+ echo "git rev-parse HEAD: " .`git rev-parse HEAD `.PHP_EOL ;
32
+ echo file_get_contents (sys_get_temp_dir ()."/out_ $ idx.txt " ).PHP_EOL ;
33
+ }
34
+ }
35
+ exit ($ final );
36
+ }
37
+
38
+ $ cmd = array_slice ($ argv , 1 );
39
+ $ cmd [0 ] = realpath ($ cmd [0 ]);
40
+
41
+ $ queue []= [getcwd (), $ cmd ];
42
+ file_put_contents ($ queueF , json_encode ($ queue ));
You can’t perform that action at this time.
0 commit comments