This repository was archived by the owner on Oct 31, 2026. It is now read-only.
Repository navigation
feat: 改成无服务器架构 - #13
Merged
Merged
Conversation
Stop keeping node-cron and systemd processes alive. Crawl and attribution now run as short slices with cursors in Postgres, triggered by Vercel Cron or GitHub Actions. Site config and crawler logs live in the database so a read-only filesystem still works.
| const $parentPost = $parentContainer.children('.post').first(); | ||
| parentId = ($parentPost.attr('id') || '').replace('post-', ''); | ||
| } | ||
| let author = '未知用户'; |
| let pageId = null; | ||
| const idMatch = html.match(/pageId\s*[:=]\s*['"]?(\d+)['"]?/i) || html.match(/page_id\s*[:=]\s*['"]?(\d+)['"]?/i); | ||
| if (idMatch) pageId = idMatch[1]; | ||
| if (!pageId) { success = true; return; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为什么
线上现在要常驻两样东西:
next start,以及node-cron拉起的auto-crawler.js/auto-attribution.js(还有一台 systemd)。无服务器平台没有这种一直活着的进程,磁盘也不可写。改成什么样
settings(crawler:cursor、attribution:cursor),调用结束进程就可以死。一轮爬虫跑完冷却 3 小时,归属同步冷却 30 分钟。vercel.json里每天一次的 Cron(Hobby 计划更密会被拒)。.github/workflows/serverless-jobs.yml每 10 分钟推进最多 8 分钟。配DATABASE_URL即可;或者只配SITE_ORIGIN+CRON_SECRET,去打/api/cron/*。/api/cron/crawl和/api/cron/attribution用CRON_SECRET鉴权,没配密钥就 401。site:config,不再依赖可写的wikitdb.config.js。爬虫日志写入logs:crawler。globalThis上,Vercel 上自动补connection_limit=1。限速在配了 Upstash 时跨实例共享。wikit全站备份留在 GitHub Actions(要二进制和磁盘),产物上传 artifact。函数里调用会直接跳过。systemctl删帖机器人在VERCEL=1时返回 501,改用已有的 BotAccount 扫描。上线前要配
DATABASE_URL(连接池地址)CRON_SECRET(至少 16 字符)DATABASE_URL,可选WIKIDOT_BOT_USER/WIKIDOT_BOT_PASSUPSTASH_REDIS_REST_URL/UPSTASH_REDIS_REST_TOKENnpm run worker还在,但跑完当前这一轮就退出,不要再交给 PM2 守护。