Chore(medusa,utils,types,inventory,stock-location): remove core dependency modules (#3531)

This commit is contained in:
Carlos R. L. Rodrigues
2023-03-23 08:07:32 -03:00
committed by GitHub
parent bfef22b33e
commit 4e9d257d3b
159 changed files with 1769 additions and 693 deletions
+36 -31
View File
@@ -18,40 +18,45 @@ export default async function ({ port, directory }) {
const app = express()
const { dbConnection } = await loaders({ directory, expressApp: app })
const serverActivity = Logger.activity(`Creating server`)
const server = GracefulShutdownServer.create(
app.listen(port, (err) => {
if (err) {
return
}
Logger.success(serverActivity, `Server is ready on port: ${port}`)
track("CLI_START_COMPLETED")
try {
const { dbConnection } = await loaders({ directory, expressApp: app })
const serverActivity = Logger.activity(`Creating server`)
const 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)
})
}
process.on("SIGTERM", gracefulShutDown)
process.on("SIGINT", gracefulShutDown)
scheduleJob(CRON_SCHEDULE, () => {
track("PING")
})
)
// 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)
})
return { dbConnection, server }
} catch (err) {
Logger.error("Error starting server", err)
process.exit(1)
}
process.on("SIGTERM", gracefulShutDown)
process.on("SIGINT", gracefulShutDown)
scheduleJob(CRON_SCHEDULE, () => {
track("PING")
})
return { dbConnection, server }
}
const { dbConnection, server } = await start()
await start()
}