mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 04:06:00 +00:00
28 lines
723 B
JavaScript
28 lines
723 B
JavaScript
const net = require('net');
|
|
const port = 5000;
|
|
|
|
process.env.ELECTRON_START_URL = `http://localhost:${port}`;
|
|
|
|
const client = new net.Socket();
|
|
|
|
let startedElectron = false;
|
|
const tryConnection = () => client.connect({port: port}, () => {
|
|
client.end();
|
|
if(!startedElectron) {
|
|
console.log('starting electron');
|
|
startedElectron = true;
|
|
const exec = require('child_process').exec;
|
|
const electron = exec('yarn electron');
|
|
electron.stdout.on("data", function(data) {
|
|
console.log("stdout: " + data.toString());
|
|
});
|
|
}
|
|
}
|
|
);
|
|
|
|
tryConnection();
|
|
|
|
client.on('error', (error) => {
|
|
setTimeout(tryConnection, 1000);
|
|
});
|