6994ba1a4e
Text generation now runs through a PM2 automation worker (codex exec) and images through the ChatGPT Chrome extension, replacing the Anthropic API. generateStructured keeps its signature; results are Zod-validated on the web side and the worker is reached with a bearer secret. - AI image assistant in the post editor: editable prompt step, then image (square or 3:2 only, since Instagram rejects 2:3), stored via putBlob - Full-post queue (PostGenerationJob + migration): enqueue returns 202, FIFO claim under an advisory lock, heartbeat, stale-job failure, per-user request key, cancel while QUEUED; output is always a DRAFT with audit rows - Separate 10 images/page/day quota; text quota excludes images - Worker reports Codex usage-limit as 429 with a clear Thai message - Docs: AI-AUTOMATION.md, ARCHITECTURE/README/.env.example updated Known gap: the live FIFO queue check (scripts/check-post-queue.mjs) has not passed yet; the last run hit the Codex account usage limit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
20 lines
850 B
JavaScript
20 lines
850 B
JavaScript
// PM2 process file for background workers. The web app itself runs on Vercel / `next start`.
|
|
// npm run worker:start → pm2 start ecosystem.config.cjs
|
|
// npm run worker:logs → pm2 logs page-analysis-worker
|
|
module.exports = {
|
|
apps: [
|
|
{ name: "page-post-generation", script: "scripts/post-generation-worker.mjs", cwd: __dirname, autorestart: true, restart_delay: 5000, max_restarts: 10, time: true, kill_timeout: 15000 },
|
|
{ name: "page-ai-automation", script: "scripts/ai-automation-worker.mjs", cwd: __dirname, autorestart: true, restart_delay: 5000, max_restarts: 10, time: true },
|
|
{
|
|
name: "page-analysis-worker",
|
|
script: "scripts/analysis-worker.mjs",
|
|
cwd: __dirname,
|
|
autorestart: true,
|
|
max_restarts: 10,
|
|
restart_delay: 5000,
|
|
kill_timeout: 15000,
|
|
time: true,
|
|
},
|
|
],
|
|
};
|