GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode/infra/stats.ts at dev · devicenull/opencode Expand file tree/ Copy pathstats.tsMore file actions 122 lines (108 loc) · 3.02 KB / Copy pathstats.tsFile metadata and controls122 lines (108 loc) · 3.02 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 import { EMAILOCTOPUS_API_KEY } from "./app" import { domain } from "./stage" // Keep the deployed names and arguments: the R2 stats sync still uses this VPC // and cluster after the legacy lake is removed. const lakeVpc = new sst.aws.Vpc("LakeVpc") const lakeCluster = new sst.aws.Cluster("LakeCluster", { vpc: lakeVpc }) //////////////// // DATABASE //////////////// const cluster = planetscale.getDatabaseOutput({ name: "opencode-stats", organization: "anomalyco", }) const branch = $app.stage === "production" ? planetscale.getBranchOutput({ name: "production", organization: cluster.organization, database: cluster.name, }) : new planetscale.Branch("StatsDatabaseBranch", { database: cluster.name, organization: cluster.organization, name: $app.stage, parentBranch: "production", }) const password = new planetscale.Password("StatsDatabasePassword", { name: $app.stage, database: cluster.name, organization: cluster.organization, branch: branch.name, }) const databaseUrl = $interpolate`mysql://${password.username.apply(encodeURIComponent)}:${password.plaintext.apply( encodeURIComponent, )}@${password.accessHostUrl}/${cluster.name}` export const database = new sst.Linkable("StatsDatabase", { properties: { host: password.accessHostUrl, database: cluster.name, username: password.username, password: password.plaintext, port: 3306, url: databaseUrl, }, }) new sst.x.DevCommand("StatsStudio", { link: [database], environment: { DATABASE_URL: databaseUrl, }, dev: { command: "bun db:studio", directory: "packages/stats/core", autostart: false, }, }) //////////////// // APP //////////////// export const app = new sst.cloudflare.x.SolidStart("Stats", { path: "packages/stats/app", buildCommand: "bun run build", domain: `stats.${domain}`, link: [database, EMAILOCTOPUS_API_KEY], environment: { PUBLIC_URL: `https://${domain}/data`, }, }) //////////////// // SERVICES //////////////// const statsSyncConfig = new sst.Linkable("StatsSyncConfig", { properties: { dataset: "zen", }, }) const r2SqlAuthToken = new sst.Secret("R2SqlAuthToken") const r2Sql = new sst.Linkable("R2Sql", { properties: { accountId: "15d29c8639fd3733b1b5486a2acfd968", bucket: `platform-${$app.stage}-lake`, namespace: "inference", table: "generation", }, }) export const statSync = new sst.aws.Service("StatsSyncService", { cluster: lakeCluster, architecture: "arm64", cpu: "0.25 vCPU", // 0.5 GB caused an OOM crash loop: every restart immediately re-ran the 4 Athena // stats queries (~$5/pass) every ~5 minutes instead of hourly. memory: "2 GB", image: { context: ".", dockerfile: "packages/stats/server/Dockerfile", }, command: ["bun", "src/stat-sync.ts"], link: [database, r2Sql, r2SqlAuthToken, statsSyncConfig], scaling: { min: 1, max: 1, }, dev: { command: "bun src/stat-sync.ts", directory: "packages/stats/server", autostart: false, }, }) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |