@@ -31,7 +31,7 @@ export async function launch(process_, job, isAsync, parameters, callback) {
31
31
return callback (
32
32
{ code : 400 , description : `addNumbersInContainer run only async` } ,
33
33
undefined
34
- ) ;
34
+ )
35
35
}
36
36
37
37
job . status = "running" ; // accepted, successful, failed, dismissed
@@ -66,22 +66,25 @@ export async function launch(process_, job, isAsync, parameters, callback) {
66
66
});
67
67
*/
68
68
69
- // get running containers
70
- let data = await docker . command ( "ps" ) ;
71
- // is our container already running?
72
- const notFound =
73
- data . containerList . findIndex ( ( element ) => element . image == containerName ) <
74
- 0 ;
75
-
76
- if ( notFound ) {
77
- const command = `run -d -p ${ port } :80 ${ containerName } ` ;
78
-
79
- let result = await docker . command ( command ) ;
80
- console . log ( result ) ;
81
- // give container time to settle
82
- await new Promise ( ( r ) => setTimeout ( r , 1000 ) ) ;
83
- } else {
84
- console . log ( `Container ${ containerName } already running. Good.` ) ;
69
+ try {
70
+ // get running containers
71
+ let data = await docker . command ( "ps" )
72
+
73
+ // is our container already running?
74
+ const notFound = data . containerList . findIndex ( ( element ) => element . image == containerName ) < 0 ;
75
+ if ( notFound ) {
76
+ const command = `run -d -p ${ port } :80 ${ containerName } ` ;
77
+
78
+ let result = await docker . command ( command ) ;
79
+ console . log ( result ) ;
80
+ // give container time to settle
81
+ await new Promise ( ( r ) => setTimeout ( r , 1000 ) ) ;
82
+ } else {
83
+ console . log ( `Container ${ containerName } already running. Good.` ) ;
84
+ }
85
+ }
86
+ catch ( err ) {
87
+ return callback ( { code : 400 , description : err . message } , undefined )
85
88
}
86
89
87
90
let content = { } ;
0 commit comments