fix: revert no server start (#6790)
**Why** - we want to start a server so we can allow health checks on workers
This commit is contained in:
@@ -24,47 +24,40 @@ export default async function ({ port, directory }) {
|
||||
expressApp: app,
|
||||
})
|
||||
|
||||
const shouldStartServer =
|
||||
configModule.projectConfig.worker_mode !== "worker"
|
||||
|
||||
let server
|
||||
if (shouldStartServer) {
|
||||
const serverActivity = Logger.activity(`Creating server`)
|
||||
server = GracefulShutdownServer.create(
|
||||
app.listen(port, (err) => {
|
||||
if (err) {
|
||||
return
|
||||
}
|
||||
Logger.success(serverActivity, `Server is ready on port: ${port}`)
|
||||
track("CLI_START_COMPLETED")
|
||||
const serverActivity = Logger.activity(`Creating server`)
|
||||
server = GracefulShutdownServer.create(
|
||||
app.listen(port, (err) => {
|
||||
if (err) {
|
||||
return
|
||||
}
|
||||
Logger.success(serverActivity, `Server is ready on port: ${port}`)
|
||||
track("CLI_START_COMPLETED")
|
||||
})
|
||||
)
|
||||
|
||||
// Handle graceful shutdown
|
||||
const gracefulShutDown = () => {
|
||||
server
|
||||
.shutdown()
|
||||
.then(() => {
|
||||
Logger.info("Gracefully stopping the server.")
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((e) => {
|
||||
Logger.error("Error received when shutting down the server.", e)
|
||||
process.exit(1)
|
||||
})
|
||||
)
|
||||
|
||||
// Handle graceful shutdown
|
||||
const gracefulShutDown = () => {
|
||||
server
|
||||
.shutdown()
|
||||
.then(() => {
|
||||
Logger.info("Gracefully stopping the server.")
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((e) => {
|
||||
Logger.error("Error received when shutting down the server.", e)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
process.on("SIGTERM", gracefulShutDown)
|
||||
process.on("SIGINT", gracefulShutDown)
|
||||
} else {
|
||||
Logger.info("Running in worker mode, server will not be started.")
|
||||
}
|
||||
|
||||
process.on("SIGTERM", gracefulShutDown)
|
||||
process.on("SIGINT", gracefulShutDown)
|
||||
|
||||
scheduleJob(CRON_SCHEDULE, () => {
|
||||
track("PING")
|
||||
})
|
||||
|
||||
return shouldStartServer ? { dbConnection, server } : { dbConnection }
|
||||
return { dbConnection, server }
|
||||
} catch (err) {
|
||||
Logger.error("Error starting server", err)
|
||||
process.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user