Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send a 'ready' message to parent process if api server was spawned #4744

Merged
merged 3 commits into from
Mar 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/api-server/src/cliHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import type { HttpServerParams } from './server'
* Also used in index.ts for the api server
*/

const sendProcessReady = () => {
return process.send && process.send('ready')
}

export const commonOptions = {
port: { default: getConfig().web?.port || 8910, type: 'number', alias: 'p' },
socket: { type: 'string' },
Expand Down Expand Up @@ -74,6 +78,7 @@ export const apiServerHandler = async ({
console.log(`API listening on ${on}`)
const graphqlEnd = c.magenta(`${apiRootPath}graphql`)
console.log(`GraphQL endpoint at ${graphqlEnd}`)
sendProcessReady()
})
process.on('exit', () => {
http?.close()
Expand Down Expand Up @@ -110,6 +115,7 @@ export const bothServerHandler = async ({
console.log(`API listening on ${on}`)
const graphqlEnd = c.magenta(`${apiRootPath}graphql`)
console.log(`GraphQL endpoint at ${graphqlEnd}`)
sendProcessReady()
})
}

Expand Down Expand Up @@ -151,6 +157,7 @@ export const webServerHandler = ({ port, socket, apiHost }: WebServerArgs) => {
const webServer = c.green(`http://localhost:${port}`)
console.log(`Web server started on ${webServer}`)
console.log(`GraphQL endpoint is set to ` + c.magenta(`${graphqlEndpoint}`))
sendProcessReady()
})
}

Expand Down