Get webserver to start

This commit is contained in:
sayhiben
2024-08-22 20:41:48 -07:00
parent a2ec543e68
commit 760534326f
3 changed files with 18 additions and 3 deletions

View File

@@ -4,7 +4,7 @@
"description": "View streams in a grid",
"main": "./.webpack/main",
"scripts": {
"start": "electron-forge start",
"start": "electron-forge start -- --control.address=http://localhost:4444 --control.username=admin --control.password=password",
"make": "electron-forge make",
"package": "electron-forge package",
"publish": "electron-forge publish",

View File

@@ -381,7 +381,8 @@ async function main(argv) {
if (argv.control.address) {
console.debug('Initializing web server...')
const webDistPath = path.join(app.getAppPath(), './web')
const webDistPath = path.join(app.getAppPath(), './.webpack/main/web')
console.debug('Web dist path:', webDistPath)
await initWebServer({
certDir: argv.cert.dir,
certProduction: argv.cert.production,

View File

@@ -40,7 +40,7 @@ function initApp({
const app = new Koa()
// silence koa printing errors when websockets close early
app.silent = true
// app.silent = true
app.use(views(webDistPath, { extension: 'ejs' }))
app.use(serveStatic(webDistPath))
@@ -264,6 +264,17 @@ export default async function initWebServer({
stateDoc,
})
console.debug(`App initialized with args:`, {
certDir,
certProduction,
email,
baseURL,
overrideHostname,
overridePort,
webDistPath,
logEnabled,
})
let server
if (protocol === 'https:' && certDir) {
const { key, cert } = await simpleCert({
@@ -277,9 +288,12 @@ export default async function initWebServer({
} else {
server = http.createServer(app.callback())
}
console.debug("Server started.")
const listen = promisify(server.listen).bind(server)
await listen(port, overrideHostname || hostname)
console.debug('Web server listening:', { hostname, port })
return { server }
}