Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

๐Ÿš€ improve fly (#450)

authored by

Thibault Le Ouay and committed by
GitHub
efe458d3 da378734

+17 -4
+6 -2
apps/server/fly.toml
··· 15 15 force_https = true 16 16 auto_stop_machines = true 17 17 auto_start_machines = true 18 - min_machines_running = 6 18 + min_machines_running = 12 19 19 processes = ["app"] 20 + [http_service.concurrency] 21 + type = "requests" 22 + hard_limit = 1000 23 + soft_limit = 500 20 24 21 25 [deploy] 22 - strategy = "canary" 26 + strategy = "bluegreen" 23 27 24 28 [[http_service.checks]] 25 29 grace_period = "10s"
+2
apps/server/src/public/index.ts
··· 1 1 import { Hono } from "hono"; 2 2 import { logger } from "hono/logger"; 3 + import { timing } from "hono/timing"; 3 4 4 5 import { status } from "./status"; 5 6 6 7 export const publicRoute = new Hono(); 7 8 publicRoute.use("*", logger()); 9 + publicRoute.use("*", timing()); 8 10 9 11 publicRoute.route("/status", status);
+9 -2
apps/server/src/public/status.ts
··· 1 1 import { Hono } from "hono"; 2 + import { endTime, setMetric, startTime } from "hono/timing"; 2 3 3 4 import { db, eq } from "@openstatus/db"; 4 5 import { monitor, monitorsToPages, page } from "@openstatus/db/src/schema"; ··· 27 28 const { slug } = c.req.param(); 28 29 29 30 const cache = await redis.get(slug); 30 - if (cache) return c.json({ status: cache }); 31 + if (cache) { 32 + setMetric(c, "OpenStatus-Cache", "HIT"); 31 33 34 + return c.json({ status: cache }); 35 + } 36 + startTime(c, "database"); 32 37 // { monitors, pages, monitors_to_pages } 33 38 const monitorData = await db 34 39 .select() ··· 37 42 .leftJoin(page, eq(monitorsToPages.pageId, page.id)) 38 43 .where(eq(page.slug, slug)) 39 44 .all(); 45 + endTime(c, "database"); 40 46 47 + startTime(c, "clickhouse"); 41 48 // { data: [{ ok, count }] } 42 49 const lastMonitorPings = await Promise.allSettled( 43 50 monitorData.map(async ({ monitors_to_pages }) => { ··· 47 54 }); 48 55 }), 49 56 ); 50 - 57 + endTime(c, "clickhouse"); 51 58 // { ok, count } 52 59 const data = lastMonitorPings.reduce( 53 60 (prev, curr) => {