- Create new @link-stack/logger package wrapping Pino for structured logging - Replace all console.log/error/warn statements across the monorepo - Configure environment-aware logging (pretty-print in dev, JSON in prod) - Add automatic redaction of sensitive fields (passwords, tokens, etc.) - Remove dead commented-out logger file from bridge-worker - Follow Pino's standard argument order (context object first, message second) - Support log levels via LOG_LEVEL environment variable - Export TypeScript types for better IDE support This provides consistent, structured logging across all applications and packages, making debugging easier and production logs more parseable.
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { run } from "graphile-worker";
|
|
import { createLogger } from "@link-stack/logger";
|
|
import * as path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const logger = createLogger('bridge-worker');
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const startWorker = async () => {
|
|
logger.info("Starting worker...");
|
|
|
|
await run({
|
|
connectionString: process.env.DATABASE_URL,
|
|
noHandleSignals: false,
|
|
concurrency: process.env.BRIDGE_WORKER_CONCURRENCY
|
|
? parseInt(process.env.BRIDGE_WORKER_CONCURRENCY, 10)
|
|
: 10,
|
|
maxPoolSize: process.env.BRIDGE_WORKER_POOL_SIZE
|
|
? parseInt(process.env.BRIDGE_WORKER_POOL_SIZE, 10)
|
|
: 10,
|
|
pollInterval: process.env.BRIDGE_WORKER_POLL_INTERVAL
|
|
? parseInt(process.env.BRIDGE_WORKER_POLL_INTERVAL, 10)
|
|
: 1000,
|
|
taskDirectory: `${__dirname}/tasks`,
|
|
crontabFile: `${__dirname}/crontab`,
|
|
});
|
|
};
|
|
|
|
const main = async () => {
|
|
await startWorker();
|
|
};
|
|
|
|
main().catch((err) => {
|
|
logger.error({ error: err }, 'Worker failed to start');
|
|
process.exit(1);
|
|
});
|