-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron-wait-react.js
More file actions
36 lines (26 loc) · 862 Bytes
/
Copy pathelectron-wait-react.js
File metadata and controls
36 lines (26 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const net = require('net');
const port = process.env.PORT ? (process.env.PORT - 100) : 3000;
const runServer = require('./server/bin/www');
process.env.ELECTRON_START_URL = `http://localhost:${port}`;
const client = new net.Socket();
let startedElectron = false;
const tryConnection = () => client.connect({port: port}, async () => {
client.end();
if(!startedElectron) {
console.log('starting electron');
startedElectron = true;
const exec = require('child_process').exec;
try {
await runServer;
// Still testing stuff with electron. For now, We're using a web application
exec('npm run electron');
} catch(err) {
console.log("SERVER FAILED!");
}
}
}
);
tryConnection();
client.on('error', (error) => {
setTimeout(tryConnection, 1000);
});