AGENT SKILL
shared-hosting-node-ops
Use when debugging Node on shared hosting: keep one copy.
- License 许可
- MIT
- 所属仓库
- iberi22/skills
- 最近更新
- 2026-10-12
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- shared-hosting-node-ops
- description
- Use when debugging Node on shared hosting: keep one copy.
03 SKILL.md 正文
Shared-Hosting Node Ops — cPanel/CloudLinux backends
Class-level workflow for Node backends living on shared cPanel hosting: no root, CloudLinux LVE limits, Node.js Selector (Passenger) available, deploys over SSH, Apache .htaccess proxy to a localhost port. Goal: one healthy copy, verified from the public internet, without ever pinning the account's process limit.
Operating policy (standing)
- Self-solve first, hosting support is last resort. Diagnose everything reachable from our side (SSH, panel UI, public curl) before opening a ticket. Open one only when the cause is invisible from the account (e.g. processes nobody owns, panel backend itself crashing).
- Support comms are non-technical. Ticket drafts state symptoms + the one action requested ("kill the stuck processes on my account and tell me what spawns them"), never runtime internals, library names, or stack traces.
- Act, don't narrate stalls. If a step blocks, say what is blocked in one line and what runs next — never end a turn with only a promise. Background deploys report back on completion.
Deploy flow (nohup worker + .htaccess proxy)
- Gate first: lint clean,
tsc --noEmit0 errors, build producesdist/index.js, unit tests green, E2E green, no secrets tracked, no dev URLs indist, deploy credentials present (never in repo —.env.deploy-style gitignored file only). - Ship minimal tarball:
dist + package.json + prismaonly. Nevernode_modules,uploads, or backups. Never print or overwrite the server.env. - On the server:
npm install --production→prisma generate(pin the CLI version — a barenpx prismacan pull a wrong major) →prisma db push. - Restart with verified death: SIGTERM the old worker matched by CWD, wait up to ~20s verifying zero remain, SIGKILL stragglers, then start the new one with
setsid nohup. Starting the new copy before the old one releases the port kills the new copy withEADDRINUSEwhile the health check still passes against the OLD copy — always confirm the PID changed. - Post-checks from the public internet:
/health(or proxy path) → 200, one auth endpoint with a dummy payload returns the generic (non-enumerating) response, the public page → 200, exactly ONE worker process for the app, thread count sane (see below).
The single-copy rule (hard)
- Exactly ONE running copy per backend, matched by process CWD (
readlink /proc/<pid>/cwd). A second copy (stale nohup + a Passenger Play, a crashed restart that didn't die) doubles thread usage and causesEADDRINUSEcrashes. - Passenger entry vs nohup: pick ONE mechanism. If the app runs as a nohup worker behind an
.htaccessproxy, astoppedPassenger entry for the same app root must stay stopped — pressing Play spawns a duplicate that fights for the same port and DB. Never delete a Passenger entry blindly (deletion may remove files); leaving it stopped is safe. - A Passenger entry whose docroot subdirectory (e.g.
public_html/<uri>/.htaccess) does not exist fails to start withFileNotFoundErrorfromclselector— that is expected when the app is served by port+proxy instead of Passenger URI mapping. Do not "fix" it by creating the directory unless migrating to Passenger serving.
CloudLinux LVE triage (NPROC counts threads)
- NPROC counts threads, not processes. A Node backend with a multithreaded engine layer (e.g. Prisma/tokio workers scale with core count) can sit at ~40+ slots while idle with CPU near zero — two copies pin a 100-slot account with nothing visibly wrong. Thread count per copy is checked with
ls /proc/<pid>/task | wc -l. - Saturation signature:
fork: Resource temporarily unavailableeverywhere, SSH authenticates but exec/SFTP channels never answer, the resource panel itself errors. Auth succeeding while channels stall rules out credential/rate-limit blocks. - When fork is dead, only shell builtins work (
echo,kill,for,[[ ]], redirection reads of/proc).ps,grep,tr,pgrep,curlall need fork+exec and fail. - Never hammer a saturated account. Each SSH attempt, panel click, and Play press spawns account processes. One probe at a time, generous waits between them; stop pressing panel buttons once NPROC is near the cap.
- Account owner vs operator: the cPanel account may belong to the client (tickets go out under their name), while deploy credentials live in the operator's local gitignored env file. Rotate any credential that ever landed in chat or repo history.
Dictating shell to the user over chat
- Chat corrupts paired asterisks in glob patterns (
*sshd*arrives assshd, silently breakingcasematches so "nothing found" looks like a clean result). When the user must paste shell from chat, match with[[ $var =~ substr1|substr2 ]]regex instead ofcaseglobs, and design every loop to print an explicit sentinel (DONE) plus per-item action lines (KILLING <pid>) so a zero-result run is distinguishable from a broken-pattern run. - Prefer panel UI paths (Resource Usage snapshot tab, Node.js Selector states) over pasted shell when the user is non-technical — screenshots transcribed via vision beat terminal output they can't copy.
04 同仓库更多 Skills
web-design-guidelines
暂无简介
★ 0
blocked-page-recovery
Use when a fetch fails: 403/429, paywall, WAF, bot wall. Recovers the page via archives and provenance-checked fallbacks.
★ 0
studio-coach
暂无简介
★ 0
src-generator
暂无简介
★ 0
sqlite-pro
暂无简介
★ 0
rigor-evaluator
Use when you need a quick heuristic rigor score (10 criteria, 0-2 each) for the features in a .gitcore/features.json file, to decide which features are ready to ship.
★ 0