docs(ops): 実効env確認の pid 取得を pgrep から pm2 jlist へ是正 - #8
Closed
appdevelopsk wants to merge 2 commits into
Closed
appdevelopsk wants to merge 2 commits into
appdevelopsk wants to merge 2 commits into
Conversation
PM2 が実行している /opt/appcfg/toolify-start.sh は VPS 上にしか存在せず、 全ブランチの履歴を通じて一度も追跡されていなかった(VPS のディスクが飛べば 復元手段がない)。現物をそのまま ops/toolify-start.sh として取り込む。 あわせて docs/DEPLOY.md に 2026-09-17〜18 の本番障害で判明した罠を記録: - rsync -az --delete の同期先に起動スクリプトを置くと毎回消える(502 の原因) - HOSTNAME=127.0.0.1 は自己 proxy の EPROTO で全ページ 500。公開ドメイン名を使う - 既定ポート 3000 は別アプリが占有しているので PORT=8500 が必須 - NODE_OPTIONS の heap 上限 300 では V8 が OOM abort する(現在 400) - dump.pm2 の古い値は実効値を汚さない。判定は /proc/<pid>/environ で行う - 上記はいずれもデプロイが「成功」表示のまま起きる(落ちるのはスモークテストだけ) deploy.yml は変更しない。自動配置は上記1点目と干渉するため反映は手動のままとする。 本番の挙動は変わらない(ドキュメントとスクリプトの保全のみ)。 Claude-Session: https://claude.ai/code/session_01ENHPNZ5ngcdrTHJ2H6oAFd
pgrep -f 'toolify.*server.js' は ssh で送った自分のコマンド文字列に 先当たりし、無関係プロセス(bash -c ...)の environ を読んで NODE_OPTIONS=300 という誤答を返していた。VPS 上で再現確認済み (pgrep が返すのは自分自身の pid のみ、本体 3950723 は含まれない)。 pm2 jlist の JSON から name=="toolify" の pid をキーで取り出す方式に変更。 実測で PORT=8500 / HOSTNAME=toolify365.com / heap=400 を正しく返すことを確認。 Claude-Session: https://claude.ai/code/session_01ENHPNZ5ngcdrTHJ2H6oAFd
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
問題
docs/DEPLOY.md(5) に記載していた実効env確認コマンドに欠陥があった。pgrep -fはプロセスの コマンドライン全体 を見るため、ssh で送った自分のコマンド文字列(bash -c ... 'toolify.*server.js' ...)に先当たりする。その結果、無関係なラッパープロセスの environ を読み、NODE_OPTIONS=300という誤答を返していた。VPS 上で再現確認済み:
本体プロセス(pid 3950723)は一度も返ってこない。
修正
pm2 jlistの JSON からname == "toolify"のpidをキーで取り出す。綴りの当てずっぽうに依存しない。実測結果:
dump.pm2に残るNODE_OPTIONS=300は誤りではなく既知の残骸で、実効値は 400 が正。今回の修正でそれを正しく読めるようになった。ドキュメント変更のみ。アプリの挙動には影響しない。
https://claude.ai/code/session_01ENHPNZ5ngcdrTHJ2H6oAFd