1
1
var hpc = require ( "../hpc_exec_wrapper/exec.js" ) ;
2
+ var spawnOpts = {
3
+ timeout : 10000
4
+ } ;
2
5
var fs = require ( "fs" ) ;
3
6
var os = require ( "os" ) ;
4
7
var path = require ( "path" ) ;
@@ -251,7 +254,7 @@ modules.clusrun = function(win_config, cmd, opts, callback){
251
254
// Insert custom command
252
255
remote_cmd . push ( cmd ) ;
253
256
254
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
257
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
255
258
// Transmit the error if any
256
259
if ( output . error ) {
257
260
if ( output . error . code === 'ETIMEDOUT' && output . stdout . startsWith ( 'Enter the password for' ) ) {
@@ -316,7 +319,7 @@ modules.wincreds = function(win_config, password, callback){
316
319
// Password
317
320
remote_cmd . push ( "/password:" + password ) ;
318
321
319
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
322
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
320
323
// Transmit the error if any
321
324
if ( output . error ) {
322
325
return callback ( output . error ) ;
@@ -380,7 +383,7 @@ winFn.nodes = function(ps, win_config, controlCmd, nodeName, callback){
380
383
remote_cmd = cmdBuilder ( win_config . binariesDir , cmdDict [ node_prefix + "nodes" ] ) ;
381
384
}
382
385
383
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
386
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
384
387
385
388
// Transmit the error if any
386
389
if ( output . error ) {
@@ -440,7 +443,7 @@ modules.psmetric = function(win_config, metricName, callback){
440
443
remote_cmd = cmdBuilder ( win_config . binariesDir , cmdDict . metrics ) ;
441
444
}
442
445
443
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
446
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
444
447
445
448
// Transmit the error if any
446
449
if ( output . error ) {
@@ -490,7 +493,7 @@ winFn.jobs = function(ps, win_config, jobId, callback){
490
493
} else {
491
494
remote_cmd = cmdBuilder ( win_config . binariesDir , cmdDict [ node_prefix + "jobs" ] ) ;
492
495
}
493
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
496
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
494
497
495
498
// Transmit the error if any
496
499
if ( output . error ) {
@@ -532,7 +535,7 @@ winFn.tasks = function(ps, win_config, jobId, callback){
532
535
533
536
remote_cmd = cmdBuilder ( win_config . binariesDir , cmdDict [ node_prefix + "task" ] , jobId ) ;
534
537
535
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
538
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
536
539
537
540
// Transmit the error if any
538
541
if ( output . error ) {
@@ -690,11 +693,21 @@ modules.winscript = function(jobArgs, localPath, callback){
690
693
toWrite += '\t\t<Task' ;
691
694
// Resources
692
695
toWrite += jobArgs . resources ;
693
- toWrite += ' Name="' + jobArgs . taskName [ task ] + '"' ;
696
+ if ( jobArgs . taskName [ task ] !== null ) {
697
+ toWrite += ' Name="' + jobArgs . taskName [ task ] + '"' ;
698
+ }
694
699
// Workdir
695
- toWrite += ' WorkDirectory="' + jobArgs . workdir [ task ] + '"' ;
700
+ if ( jobArgs . workdir [ task ] !== null ) {
701
+ toWrite += ' WorkDirectory="' + jobArgs . workdir [ task ] + '"' ;
702
+ }
696
703
//Stdout and err
697
- toWrite += ' StdOutFilePath="' + jobArgs . stdout [ task ] + '" StdErrFilePath="' + jobArgs . stderr [ task ] + '"' ;
704
+ if ( jobArgs . stdout [ task ] !== null ) {
705
+ toWrite += ' StdOutFilePath="' + jobArgs . stdout [ task ] + '"' ;
706
+ }
707
+ if ( jobArgs . stderr [ task ] !== null ) {
708
+ toWrite += ' StdErrFilePath="' + jobArgs . stderr [ task ] + '"' ;
709
+ }
710
+
698
711
//Command
699
712
toWrite += ' CommandLine="' + jobArgs . commands [ task ] + '"' ;
700
713
//End
@@ -747,7 +760,7 @@ modules.winmodify = function(win_config, jobId, jobSettings, callback){
747
760
}
748
761
749
762
// Submit
750
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
763
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
751
764
752
765
// Transmit the error if any
753
766
if ( output . error ) {
@@ -777,7 +790,7 @@ modules.submit = function(win_config, jobArgs, jobWorkingDir, callback){
777
790
for ( var i = 0 ; i < jobArgs . length ; i ++ ) {
778
791
// Copy only different files
779
792
if ( path . normalize ( jobArgs [ i ] ) !== path . join ( jobWorkingDir , path . basename ( jobArgs [ i ] ) ) ) {
780
- var copyCmd = hpc . spawn ( [ jobArgs [ i ] , jobWorkingDir ] , "copy" , null , win_config ) ;
793
+ var copyCmd = hpc . spawn ( [ jobArgs [ i ] , jobWorkingDir ] , "copy" , null , win_config , spawnOpts ) ;
781
794
if ( copyCmd . error ) {
782
795
return callback ( new Error ( copyCmd . error ) ) ;
783
796
}
@@ -832,7 +845,7 @@ modules.psgroups = function(win_config, groupName, callback){
832
845
} else {
833
846
remote_cmd = cmdBuilder ( win_config . binariesDir , cmdDict . groups ) ;
834
847
}
835
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
848
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
836
849
837
850
// Transmit the error if any
838
851
if ( output . error ) {
@@ -880,7 +893,7 @@ winFn.cancel = function(ps, win_config, jobId, callback){
880
893
remote_cmd = cmdBuilder ( win_config . binariesDir , cmdDict [ node_prefix + "cancel" ] , jobId ) ;
881
894
}
882
895
883
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config ) ;
896
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , spawnOpts ) ;
884
897
885
898
// Transmit the error if any
886
899
if ( output . error ) {
@@ -905,7 +918,7 @@ modules.windir = function(win_config, jobId, callback){
905
918
}
906
919
// TOOD: put in config file
907
920
var remote_cmd = [ "dir" , "/s" , jobWorkingDir ] ;
908
- var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , { shell : true } ) ;
921
+ var output = hpc . spawn ( remote_cmd , "shell" , null , win_config , { shell : true , timeout : spawnOpts . timeout } ) ;
909
922
910
923
// Transmit the error if any
911
924
if ( output . error ) {
0 commit comments