()
| 305 | let pingStartTime = (new Date).getTime(); |
| 306 | |
| 307 | function performPing() { |
| 308 | // If ping request is already send and response is not |
| 309 | // received no need to send another request. |
| 310 | if (pingInProgress) { |
| 311 | pingTimeoutID = setTimeout(performPing, currentPingInterval); |
| 312 | return; |
| 313 | } |
| 314 | |
| 315 | pingInProgress = true; |
| 316 | pingServer().then(() => { |
| 317 | pingInProgress = false; |
| 318 | splashWindow.webContents.executeJavaScript('document.getElementById(\'loader-text-status\').innerHTML = \'pgAdmin 4 started\';', true); |
| 319 | // Set the pgAdmin process object to misc |
| 320 | misc.setProcessObject(pgadminServerProcess); |
| 321 | |
| 322 | clearTimeout(pingTimeoutID); |
| 323 | let appEndTime = (new Date).getTime(); |
| 324 | misc.writeServerLog('------------------------------------------'); |
| 325 | misc.writeServerLog('Total time taken to ping pgAdmin4 server: ' + (appEndTime - pingStartTime) / 1000 + ' Sec'); |
| 326 | misc.writeServerLog('------------------------------------------'); |
| 327 | misc.writeServerLog('Total launch time of pgAdmin4: ' + (appEndTime - appStartTime) / 1000 + ' Sec'); |
| 328 | misc.writeServerLog('------------------------------------------'); |
| 329 | launchPgAdminWindow(); |
| 330 | }).catch(() => { |
| 331 | pingInProgress = false; |
| 332 | let curTime = (new Date).getTime(); |
| 333 | // if the connection timeout has lapsed then throw an error |
| 334 | // and stop pinging the server. |
| 335 | if (curTime >= endTime) { |
| 336 | showErrorDialog(pingTimeoutID); |
| 337 | return; |
| 338 | } |
| 339 | |
| 340 | if (curTime > midTime1) { |
| 341 | if (curTime < midTime2) { |
| 342 | splashWindow.webContents.executeJavaScript('document.getElementById(\'loader-text-status\').innerHTML = \'Taking longer than usual...\';', true); |
| 343 | } else { |
| 344 | splashWindow.webContents.executeJavaScript('document.getElementById(\'loader-text-status\').innerHTML = \'Almost there...\';', true); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | pingTimeoutID = setTimeout(performPing, currentPingInterval); |
| 349 | if (currentPingInterval < 1000) { |
| 350 | currentPingInterval = Math.min(currentPingInterval * 2, 1000); |
| 351 | } |
| 352 | }); |
| 353 | } |
| 354 | |
| 355 | performPing(); |
| 356 | } |
no test coverage detected