feat: add code queue services and baidu netdisk
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
FROM oven/bun:1-alpine
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /app/src/components/microservices/project-manager
|
||||
COPY src/components/microservices/project-manager/package.json ./package.json
|
||||
RUN bun install --production
|
||||
COPY src/components/microservices/project-manager/tsconfig.json ./tsconfig.json
|
||||
COPY src/components/shared /app/src/components/shared
|
||||
COPY src/components/microservices/project-manager/src ./src
|
||||
|
||||
EXPOSE 4233
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { createHash, randomUUID } from "node:crypto";
|
||||
import { appendFileSync, mkdirSync } from "node:fs";
|
||||
import { dirname } from "node:path";
|
||||
import postgres from "postgres";
|
||||
import * as XLSX from "xlsx";
|
||||
import { createHourlyJsonlWriter, logRetentionBytesForService } from "../../../shared/src/rotating-jsonl";
|
||||
|
||||
type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
|
||||
type JsonRecord = Record<string, JsonValue>;
|
||||
@@ -96,15 +95,22 @@ function configFromEnv(): RuntimeConfig {
|
||||
|
||||
const config = configFromEnv();
|
||||
const sql = postgres(config.databaseUrl, { max: 8, idle_timeout: 20, connect_timeout: 10 });
|
||||
const logWriter = config.logFile
|
||||
? createHourlyJsonlWriter({
|
||||
baseLogFile: config.logFile,
|
||||
service: "project-manager",
|
||||
maxBytes: logRetentionBytesForService("project-manager"),
|
||||
})
|
||||
: null;
|
||||
logWriter?.prune();
|
||||
|
||||
function log(event: string, detail: JsonRecord = {}): void {
|
||||
const record: JsonRecord = { at: new Date().toISOString(), event, ...detail };
|
||||
recentLogs.push(record);
|
||||
if (recentLogs.length > 300) recentLogs.shift();
|
||||
if (config.logFile) {
|
||||
if (logWriter !== null) {
|
||||
try {
|
||||
mkdirSync(dirname(config.logFile), { recursive: true });
|
||||
appendFileSync(config.logFile, `${JSON.stringify(record)}\n`, "utf8");
|
||||
logWriter.appendJson(record, new Date(String(record.at)));
|
||||
} catch {
|
||||
// Logging must not break request handling.
|
||||
}
|
||||
|
||||
@@ -13,5 +13,6 @@
|
||||
"outDir": "dist",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
"include": ["src/**/*.ts"],
|
||||
"references": [{ "path": "../../shared" }]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user