@@ -5,6 +5,11 @@ if (process.argv[2] == '--verbose')
5
5
else
6
6
global . logLevel = "info" ;
7
7
8
+ if ( process . argv [ 2 ] == 'init' ) {
9
+ require ( './init.js' ) ;
10
+ return ;
11
+ }
12
+
8
13
var Log = require ( '../lib/logger' ) ,
9
14
logger = new Log ( global . logLevel ) ,
10
15
BrowserStack = require ( 'browserstack' ) ,
@@ -30,6 +35,7 @@ function terminateAllWorkers(callback) {
30
35
if ( worker ) {
31
36
logger . debug ( '[%s] Terminated' , worker . string ) ;
32
37
clearTimeout ( worker . activityTimeout ) ;
38
+ clearTimeout ( worker . testActivityTimeout ) ;
33
39
delete workers [ key ] ;
34
40
delete workerKeys [ worker . id ] ;
35
41
}
@@ -215,7 +221,7 @@ var statusPoller = {
215
221
}
216
222
} , activityTimeout * 1000 ) ;
217
223
218
- setTimeout ( function ( ) {
224
+ worker . testActivityTimeout = setTimeout ( function ( ) {
219
225
if ( worker . acknowledged ) {
220
226
var subject = "Tests timed out on: " + worker . string ;
221
227
var content = "Worker details:\n" + JSON . stringify ( worker . config , null , 4 ) ;
@@ -275,21 +281,16 @@ function runTests() {
275
281
}
276
282
277
283
try {
278
- if ( process . argv [ 2 ] == 'init' ) {
279
- require ( './init.js' ) ;
280
- } else {
281
- var client = BrowserStack . createClient ( {
282
- username : config . username ,
283
- password : config . key
284
- } ) ;
285
- runTests ( ) ;
286
- var pid_file = process . cwd ( ) + '/browserstack-run.pid' ;
287
- fs . writeFileSync ( pid_file , process . pid , 'utf-8' )
288
- process . on ( 'SIGINT' , function ( ) { cleanUpAndExit ( 'SIGINT' , 1 ) } ) ;
289
- process . on ( 'SIGTERM' , function ( ) { cleanUpAndExit ( 'SIGTERM' , config . status ) } ) ;
290
- }
284
+ var client = BrowserStack . createClient ( {
285
+ username : config . username ,
286
+ password : config . key
287
+ } ) ;
288
+ runTests ( ) ;
289
+ var pid_file = process . cwd ( ) + '/browserstack-run.pid' ;
290
+ fs . writeFileSync ( pid_file , process . pid , 'utf-8' )
291
+ process . on ( 'SIGINT' , function ( ) { cleanUpAndExit ( 'SIGINT' , 1 ) } ) ;
292
+ process . on ( 'SIGTERM' , function ( ) { cleanUpAndExit ( 'SIGTERM' , config . status ) } ) ;
291
293
} catch ( e ) {
292
294
console . log ( e ) ;
293
295
console . log ( 'Invalid command.' ) ;
294
296
}
295
-
0 commit comments