@@ -89,6 +89,7 @@ Server.prototype.queryStatus = function () {
89
89
self . state = null
90
90
} else {
91
91
self . state = state
92
+ self . startHeadlessClientsIfNeeded ( )
92
93
}
93
94
94
95
self . emit ( 'state' )
@@ -178,19 +179,25 @@ Server.prototype.start = function () {
178
179
179
180
this . pid = instance . pid
180
181
this . instance = instance
182
+ this . headlessClientInstances = [ ]
181
183
this . queryStatusInterval = setInterval ( function ( ) {
182
184
self . queryStatus ( )
183
185
} , queryInterval )
184
186
185
- this . startHeadlessClients ( )
186
-
187
- this . logs . logServerProcesses ( this . id , this . instance , this . headlessClientInstances )
187
+ this . logs . logServerProcess ( this . instance , this . id , 'server' )
188
+ this . logs . cleanupOldLogFiles ( )
188
189
189
190
this . emit ( 'state' )
190
191
191
192
return this
192
193
}
193
194
195
+ Server . prototype . startHeadlessClientsIfNeeded = function ( ) {
196
+ if ( this . number_of_headless_clients > 0 && this . headlessClientInstances . length === 0 ) {
197
+ this . startHeadlessClients ( )
198
+ }
199
+ }
200
+
194
201
Server . prototype . startHeadlessClients = function ( ) {
195
202
var parameters = this . getParameters ( )
196
203
var self = this
@@ -207,6 +214,7 @@ Server.prototype.startHeadlessClients = function () {
207
214
port : self . port
208
215
} )
209
216
var headlessInstance = headless . start ( )
217
+ self . logs . logServerProcess ( headlessInstance , self . id , 'hc_' + ( i + 1 ) )
210
218
return headlessInstance
211
219
} )
212
220
@@ -245,6 +253,7 @@ Server.prototype.stopHeadlessClients = function () {
245
253
this . headlessClientInstances . map ( function ( headlessClientInstance ) {
246
254
headlessClientInstance . kill ( )
247
255
} )
256
+ this . headlessClientInstances = [ ]
248
257
}
249
258
250
259
Server . prototype . toJSON = function ( ) {
0 commit comments