()
| 217 | // This functions is used to start the pgAdmin4 server by spawning a |
| 218 | // separate process. |
| 219 | function startDesktopMode() { |
| 220 | // Return if pgAdmin server process is already spawned |
| 221 | // Added check for debugging purpose. |
| 222 | if (pgadminServerProcess != null) |
| 223 | return; |
| 224 | |
| 225 | let pingTimeoutID; |
| 226 | // Set the environment variables so that pgAdmin 4 server |
| 227 | // starts listening on the appropriate port. |
| 228 | process.env.PGADMIN_INT_PORT = serverPort; |
| 229 | process.env.PGADMIN_INT_KEY = UUID; |
| 230 | process.env.PGADMIN_SERVER_MODE = 'OFF'; |
| 231 | |
| 232 | // Prevent Python from writing .pyc files to the signed bundle |
| 233 | process.env.PYTHONDONTWRITEBYTECODE = '1'; |
| 234 | |
| 235 | // Start Page URL |
| 236 | baseUrl = `http://127.0.0.1:${serverPort}`; |
| 237 | startPageUrl = `${baseUrl}/?key=${UUID}`; |
| 238 | serverCheckUrl = `${baseUrl}/misc/ping?key=${UUID}`; |
| 239 | |
| 240 | // Write Python Path, pgAdmin file path and command in log file. |
| 241 | misc.writeServerLog('pgAdmin Runtime Environment'); |
| 242 | misc.writeServerLog('--------------------------------------------------------'); |
| 243 | let command = pythonPath + ' -s ' + pgadminFile; |
| 244 | misc.writeServerLog('Python Path: "' + pythonPath + '"'); |
| 245 | misc.writeServerLog('Runtime Config File: "' + path.resolve(configStore.path) + '"'); |
| 246 | misc.writeServerLog('Webapp Path: "' + pgadminFile + '"'); |
| 247 | misc.writeServerLog('pgAdmin Command: "' + command + '"'); |
| 248 | misc.writeServerLog('Environment: '); |
| 249 | Object.keys(process.env).forEach(function (key) { |
| 250 | // Below code is included only for Mac OS as default path for azure CLI |
| 251 | // installation path is not included in PATH variable while spawning |
| 252 | // runtime environment. |
| 253 | if (process.platform === 'darwin' && key === 'PATH') { |
| 254 | let updated_path = process.env[key] + ':/usr/local/bin'; |
| 255 | process.env[key] = updated_path; |
| 256 | } |
| 257 | |
| 258 | if (process.platform === 'win32' && key.toUpperCase() === 'PATH') { |
| 259 | let _libpq_path = path.join(path.dirname(path.dirname(path.resolve(pgadminFile))), 'runtime'); |
| 260 | process.env[key] = _libpq_path + ';' + process.env[key]; |
| 261 | } |
| 262 | |
| 263 | misc.writeServerLog(' - ' + key + ': ' + process.env[key]); |
| 264 | }); |
| 265 | misc.writeServerLog('--------------------------------------------------------\n'); |
| 266 | |
| 267 | // Spawn the process to start pgAdmin4 server. |
| 268 | let spawnStartTime = (new Date).getTime(); |
| 269 | pgadminServerProcess = spawn(pythonPath, ['-s', pgadminFile]); |
| 270 | pgadminServerProcess.on('error', function (err) { |
| 271 | // Log the error into the log file if process failed to launch |
| 272 | misc.writeServerLog('Failed to launch pgAdmin4. Error:'); |
| 273 | misc.writeServerLog(err); |
| 274 | showErrorDialog(pingTimeoutID); |
| 275 | }); |
| 276 |
no test coverage detected