MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / start

Function start

apps/worker/src/index.ts:33–174  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31sourceMapSupport.install();
32
33async function start() {
34 const collectDefaultMetrics = client.collectDefaultMetrics;
35 collectDefaultMetrics({ register });
36
37 const PORT = Number.parseInt(process.env.WORKER_PORT || '3000', 10);
38 const app = express();
39
40 // Local-only: trigger cron jobs on demand. Disabled in production. Mounted
41 // before bull-board so its routes take precedence.
42 if (process.env.NODE_ENV !== 'production') {
43 bootDebugRoutes(app);
44 }
45
46 if (
47 process.env.DISABLE_BULLBOARD !== '1' &&
48 process.env.DISABLE_BULLBOARD !== 'true'
49 ) {
50 const serverAdapter = new ExpressAdapter();
51 serverAdapter.setBasePath('/');
52 createBullBoard({
53 queues: [
54 ...eventsGroupQueues.map(
55 (queue) => new BullBoardGroupMQAdapter(queue) as any
56 ),
57 new BullMQAdapter(sessionsQueue),
58 new BullMQAdapter(cronQueue),
59 new BullMQAdapter(notificationQueue),
60 new BullMQAdapter(importQueue),
61 new BullMQAdapter(insightsQueue),
62 new BullMQAdapter(gscQueue),
63 new BullMQAdapter(cohortComputeQueue),
64 ],
65 serverAdapter,
66 });
67
68 app.use('/', serverAdapter.getRouter());
69 }
70
71 app.get('/metrics', (req, res) => {
72 res.set('Content-Type', register.contentType);
73 register
74 .metrics()
75 .then((metrics) => {
76 res.end(metrics);
77 })
78 .catch((error) => {
79 res.status(500).end(error);
80 });
81 });
82
83 app.get('/healthcheck', async (req, res) => {
84 const [redisResult, dbResult, chResult] = await Promise.all([
85 tryCatch(async () => (await getRedisCache().ping()) === 'PONG'),
86 tryCatch(async () => !!(await db.$executeRaw`SELECT 1`)),
87 tryCatch(async () => (await chQuery('SELECT 1')).length > 0),
88 ]);
89
90 const dependencies = {

Callers 1

index.tsFile · 0.85

Calls 15

bootDebugRoutesFunction · 0.90
tryCatchFunction · 0.90
getRedisCacheFunction · 0.90
chQueryFunction · 0.90
isShuttingDownFunction · 0.90
getEventsHeartbeatFunction · 0.90
bootWorkersFunction · 0.90
bootCronFunction · 0.90
createInitialSaltsFunction · 0.90
useMethod · 0.80
mapMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected