|
|
|
@ -38,9 +38,7 @@ if (isDevelopment) {
|
|
|
|
const queue = []
|
|
|
|
const queue = []
|
|
|
|
const queueLength = 5
|
|
|
|
const queueLength = 5
|
|
|
|
|
|
|
|
|
|
|
|
/** start Lean Server processes to refill the queue */
|
|
|
|
function startServerProcess() {
|
|
|
|
function fillQueue() {
|
|
|
|
|
|
|
|
while (queue.length < queueLength) {
|
|
|
|
|
|
|
|
const serverProcess = cp.spawn(cmd, cmdArgs, { cwd })
|
|
|
|
const serverProcess = cp.spawn(cmd, cmdArgs, { cwd })
|
|
|
|
serverProcess.on('error', error =>
|
|
|
|
serverProcess.on('error', error =>
|
|
|
|
console.error(`Launching Lean Server failed: ${error}`)
|
|
|
|
console.error(`Launching Lean Server failed: ${error}`)
|
|
|
|
@ -50,7 +48,13 @@ function fillQueue() {
|
|
|
|
console.error(`Lean Server: ${data}`)
|
|
|
|
console.error(`Lean Server: ${data}`)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return serverProcess
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** start Lean Server processes to refill the queue */
|
|
|
|
|
|
|
|
function fillQueue() {
|
|
|
|
|
|
|
|
while (queue.length < queueLength) {
|
|
|
|
|
|
|
|
const serverProcess = startServerProcess()
|
|
|
|
queue.push(serverProcess)
|
|
|
|
queue.push(serverProcess)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -58,9 +62,13 @@ function fillQueue() {
|
|
|
|
fillQueue()
|
|
|
|
fillQueue()
|
|
|
|
|
|
|
|
|
|
|
|
wss.addListener("connection", function(ws) {
|
|
|
|
wss.addListener("connection", function(ws) {
|
|
|
|
|
|
|
|
let ps;
|
|
|
|
const ps = queue.shift() // Pick the first Lean process; it's likely to be ready immediately
|
|
|
|
if (isDevelopment) { // Don't use queue in development
|
|
|
|
|
|
|
|
ps = startServerProcess()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ps = queue.shift() // Pick the first Lean process; it's likely to be ready immediately
|
|
|
|
fillQueue()
|
|
|
|
fillQueue()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const socket = {
|
|
|
|
const socket = {
|
|
|
|
onMessage: (cb) => { ws.on("message", cb) },
|
|
|
|
onMessage: (cb) => { ws.on("message", cb) },
|
|
|
|
|