chore: add telemetry ping (#1509)
* chore: add telemetry ping * fix: add track and 6th hour
This commit is contained in:
1 parent
5414148254
commit
ad9cfedf04
3 files changed
+48
-7
No files matched your search
@@ -77,6 +77,7 @@
|
||||
"medusa-test-utils": "^1.1.37",
|
||||
"morgan": "^1.9.1",
|
||||
"multer": "^1.4.2",
|
||||
"node-schedule": "^2.1.0",
|
||||
"passport": "^0.4.0",
|
||||
"passport-http-bearer": "^1.0.1",
|
||||
"passport-jwt": "^4.0.0",
|
||||
|
||||
@@ -3,11 +3,15 @@ import "regenerator-runtime/runtime"
|
||||
|
||||
import express from "express"
|
||||
import { track } from "medusa-telemetry"
|
||||
import { scheduleJob } from "node-schedule"
|
||||
|
||||
import loaders from "../loaders"
|
||||
import Logger from "../loaders/logger"
|
||||
|
||||
export default async function({ port, directory }) {
|
||||
const EVERY_SIXTH_HOUR = "* */6 * * *"
|
||||
const CRON_SCHEDULE = EVERY_SIXTH_HOUR
|
||||
|
||||
export default async function ({ port, directory }) {
|
||||
async function start() {
|
||||
track("CLI_START")
|
||||
|
||||
@@ -15,7 +19,7 @@ export default async function({ port, directory }) {
|
||||
|
||||
const { dbConnection } = await loaders({ directory, expressApp: app })
|
||||
const serverActivity = Logger.activity(`Creating server`)
|
||||
const server = app.listen(port, err => {
|
||||
const server = app.listen(port, (err) => {
|
||||
if (err) {
|
||||
return
|
||||
}
|
||||
@@ -23,6 +27,10 @@ export default async function({ port, directory }) {
|
||||
track("CLI_START_COMPLETED")
|
||||
})
|
||||
|
||||
scheduleJob(CRON_SCHEDULE, () => {
|
||||
track("PING")
|
||||
})
|
||||
|
||||
return { dbConnection, server }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user