Skip to content

Commit ef5d521

Browse files
committed
fixing electron
1 parent 8188c9f commit ef5d521

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

  • benchmesh-serial-service/src/benchmesh_service
  • electron

benchmesh-serial-service/src/benchmesh_service/api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def _mount_static_ui_if_built(app: FastAPI):
8383
if os.path.isdir(dist_dir):
8484
app.mount("/ui", StaticFiles(directory=dist_dir, html=True), name="ui")
8585

86+
# Add root redirect to UI
87+
@app.get("/")
88+
async def root_redirect():
89+
return RedirectResponse(url="/ui/")
90+
8691

8792
def _coerce_arg(v: str) -> Any:
8893
s = v.strip()

electron/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function stopProcesses() {
155155
})
156156
}
157157

158-
async function waitForBackend(retries = 20, delay = 500) {
158+
async function waitForBackend(retries = 30, delay = 1000) {
159159
for (let i = 0; i < retries; i++) {
160160
try {
161161
const http = require('http')
@@ -164,14 +164,16 @@ async function waitForBackend(retries = 20, delay = 500) {
164164
resolve(res.statusCode === 200)
165165
})
166166
req.on('error', () => resolve(false))
167-
req.setTimeout(1000, () => {
167+
req.setTimeout(2000, () => {
168168
req.destroy()
169169
resolve(false)
170170
})
171171
})
172172

173173
if (response) {
174174
console.log('Backend is ready!')
175+
// Give it a bit more time to fully initialize
176+
await new Promise(resolve => setTimeout(resolve, 1000))
175177
return true
176178
}
177179
} catch (err) {

0 commit comments

Comments
 (0)