Skip to content

Commit

Permalink
fix: annoying dev output when starting the server
Browse files Browse the repository at this point in the history
This might be possible to enable with a future flag (in the future)
  • Loading branch information
mikavilpas committed Nov 28, 2024
1 parent 54f7045 commit 729d43d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/library/src/server/TestServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,34 @@ export class TestServer {
} catch (e) {
// This is normal when developing the tui-sandbox library locally. It
// should always exist when using it as an npm package, however.
console.log(`⚠️ Warning: the tui-sandbox root contents directory is not accessible at: ${publicPath}`)
console.log(
`⚠️ Warning: Looks like the tui-sandbox root contents directory is not accessible at: ${publicPath}`
)
}

// eslint-disable-next-line import-x/no-named-as-default-member
app.use(express.static(publicPath))
}

app.use("/ping", (_, res) => {
console.log("🏓 received /ping")
// console.log("🏓 received /ping")
res.send("pong")
})

const server = app.listen(this.settings.port, "0.0.0.0")

server.on("connection", socket => {
const connectionInfo = `${socket.remoteAddress}:${socket.remotePort}`
console.log(`➕➕ Connection from ${connectionInfo}`)
// const connectionInfo = `${socket.remoteAddress}:${socket.remotePort}`
// console.log(`➕➕ Connection from ${connectionInfo}`)
socket.once("close", () => {
console.log(`➖➖ Connection from ${connectionInfo}`)
// console.log(`➖➖ Connection from ${connectionInfo}`)
})
})

console.log(`✅ Server listening on port ${this.settings.port}`)

await Promise.race([once(process, "SIGTERM"), once(process, "SIGINT")])
console.log("Shutting down...")
console.log("😴 Shutting down...")
server.close(error => {
if (error) {
console.error("Error closing server", error)
Expand Down

0 comments on commit 729d43d

Please sign in to comment.