forked from extern/easydiffusion
Improved serverState tracking
This commit is contained in:
parent
cbdf03450d
commit
982b5221b1
@ -117,7 +117,7 @@ maskResetButton.innerHTML = 'Clear'
|
|||||||
maskResetButton.style.fontWeight = 'normal'
|
maskResetButton.style.fontWeight = 'normal'
|
||||||
maskResetButton.style.fontSize = '10pt'
|
maskResetButton.style.fontSize = '10pt'
|
||||||
|
|
||||||
let serverState = {'status': 'Offline'}
|
let serverState = {'status': 'Offline', 'time': Date.now()}
|
||||||
let activeTags = []
|
let activeTags = []
|
||||||
let modifiers = []
|
let modifiers = []
|
||||||
let lastPromptUsed = ''
|
let lastPromptUsed = ''
|
||||||
@ -288,6 +288,10 @@ async function healthCheck() {
|
|||||||
res = await fetch('/ping')
|
res = await fetch('/ping')
|
||||||
}
|
}
|
||||||
serverState = await res.json()
|
serverState = await res.json()
|
||||||
|
if (typeof serverState !== 'object' || typeof serverState.status !== 'string') {
|
||||||
|
serverState = {'status': 'Offline', 'time': Date.now()}
|
||||||
|
return
|
||||||
|
}
|
||||||
// Set status
|
// Set status
|
||||||
switch(serverState.status) {
|
switch(serverState.status) {
|
||||||
case 'Init':
|
case 'Init':
|
||||||
@ -308,6 +312,7 @@ async function healthCheck() {
|
|||||||
}
|
}
|
||||||
serverState.time = Date.now()
|
serverState.time = Date.now()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
serverState = {'status': 'Offline', 'time': Date.now()}
|
||||||
setServerStatus('error', 'offline')
|
setServerStatus('error', 'offline')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -544,7 +549,7 @@ async function doMakeImage(task) {
|
|||||||
if (serverState.session !== 'pending' && serverState.session !== 'running' && serverState.session !== 'buffer') {
|
if (serverState.session !== 'pending' && serverState.session !== 'running' && serverState.session !== 'buffer') {
|
||||||
throw new Error('Unexpected server task state: ' + serverState.session || 'Undefined')
|
throw new Error('Unexpected server task state: ' + serverState.session || 'Undefined')
|
||||||
}
|
}
|
||||||
while (serverState?.session === 'pending') {
|
while (serverState.task === renderRequest.task && serverState.session === 'pending') {
|
||||||
// Wait for task to start on server.
|
// Wait for task to start on server.
|
||||||
await asyncDelay(1500)
|
await asyncDelay(1500)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user