Skip to content

Commit

Permalink
serve web: Fix socket support (#8936)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored and jtoar committed Jul 20, 2023
1 parent dbcde88 commit fdc9a17
Showing 1 changed file with 36 additions and 12 deletions.
48 changes: 36 additions & 12 deletions packages/cli/src/commands/serveHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ export const apiServerHandler = async (options) => {
},
})

fastify.listen({
port: socket ? parseInt(socket) : port,
host: process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::',
})
let listenOptions

if (socket) {
listenOptions = { path: socket }
} else {
listenOptions = {
port,
host: process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::',
}
}

fastify.listen(listenOptions)

fastify.ready(() => {
fastify.log.trace(
Expand Down Expand Up @@ -79,10 +87,18 @@ export const bothServerHandler = async (options) => {
},
})

fastify.listen({
port: socket ? parseInt(socket) : port,
host: process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::',
})
let listenOptions

if (socket) {
listenOptions = { path: socket }
} else {
listenOptions = {
port,
host: process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::',
}
}

fastify.listen(listenOptions)

fastify.ready(() => {
console.log(chalk.italic.dim('Took ' + (Date.now() - tsServer) + ' ms'))
Expand Down Expand Up @@ -136,10 +152,18 @@ export const webServerHandler = async (options) => {
fastify.register(withApiProxy, { apiHost, apiUrl })
}

fastify.listen({
port: socket ? parseInt(socket) : port,
host: process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::',
})
let listenOptions

if (socket) {
listenOptions = { path: socket }
} else {
listenOptions = {
port,
host: process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::',
}
}

fastify.listen(listenOptions)

fastify.ready(() => {
console.log(chalk.italic.dim('Took ' + (Date.now() - tsServer) + ' ms'))
Expand Down

0 comments on commit fdc9a17

Please sign in to comment.