@@ -3,35 +3,35 @@ var spawn = require('child_process').spawn;
33// Spawns a job "node handler.js" and waits for the notification of its
44// completion using the Redis task status notification mechanism
55async function task_status_redis_test ( ins , outs , context , cb ) {
6- var n = Number ( ins . number . data [ 0 ] ) ;
7-
8- //console.log("Spawning process...");
9-
10- var proc = spawn ( 'node' , [ 'handler.js' , context . taskId , context . redis_url ] ) ;
11-
12- proc . stderr . on ( 'data' , function ( data ) {
13- console . log ( data . toString ( ) ) ;
14- } ) ;
15-
16- proc . stdout . on ( 'data' , function ( data ) {
17- console . log ( data . toString ( ) ) ;
18- } ) ;
19-
20- proc . on ( 'exit' , function ( code ) {
21- //console.log('Process exited with code', code);
22- } ) ;
23-
24- // wait for the task to finish (timeout=0 means indefinite)
25- try {
26- var taskStatus = await context . taskStatus ( 0 ) ;
27- console . log ( 'Received task status:' , taskStatus ) ;
28- setTimeout ( function ( ) {
29- cb ( null , outs ) ;
30- } , 5000 ) ;
31- } catch ( err ) {
32- console . err ( err ) ;
33- throw err ;
34- }
6+ var n = Number ( ins . number . data [ 0 ] ) ;
7+
8+ //console.log("Spawning process...");
9+
10+ var proc = spawn ( 'node' , [ 'handler.js' , context . taskId , context . redis_url ] ) ;
11+
12+ proc . stderr . on ( 'data' , function ( data ) {
13+ console . log ( data . toString ( ) ) ;
14+ } ) ;
15+
16+ proc . stdout . on ( 'data' , function ( data ) {
17+ console . log ( data . toString ( ) ) ;
18+ } ) ;
19+
20+ proc . on ( 'exit' , function ( code ) {
21+ //console.log('Process exited with code', code);
22+ } ) ;
23+
24+ // wait for the task to finish (timeout=0 means indefinite)
25+ try {
26+ var taskStatus = await context . taskStatus ( 0 ) ;
27+ console . log ( 'Received task status:' , taskStatus ) ;
28+ setTimeout ( function ( ) {
29+ cb ( null , outs ) ;
30+ } , 5000 ) ;
31+ } catch ( err ) {
32+ console . err ( err ) ;
33+ throw err ;
34+ }
3535}
3636
3737exports . task_status_redis_test = task_status_redis_test ;
0 commit comments