diff --git a/SKILL.md b/SKILL.md index a3a5563..a0406b6 100644 --- a/SKILL.md +++ b/SKILL.md @@ -109,19 +109,23 @@ pm2 save pm2 startup # follow the printed command (requires sudo) ``` -**PM2 cheatsheet:** -```bash -pm2 list # show all jobs + status -pm2 logs claw-searcher # tail searcher logs -pm2 logs claw-applier # tail applier logs -pm2 start claw-applier # enable applier -pm2 stop claw-applier # pause applier -pm2 restart claw-searcher # restart searcher now +PM2 manages the processes but **does not schedule them** — scheduling is handled by system cron. This ensures a running searcher is never killed mid-run. If it's already running, the cron invocation hits the lockfile and exits immediately. + +Add to crontab (`crontab -e`): +``` +0 * * * * cd /path/to/claw-apply && node job_searcher.mjs >> /tmp/claw-searcher.log 2>&1 +0 */6 * * * cd /path/to/claw-apply && node job_applier.mjs >> /tmp/claw-applier.log 2>&1 ``` -Schedules (set in `ecosystem.config.cjs`): -- **Searcher**: `0 * * * *` (hourly) -- **Applier**: `0 */6 * * *` (every 6h) — stopped by default, start when ready +**PM2 cheatsheet:** +```bash +pm2 list # show all processes + status +pm2 logs claw-searcher # tail searcher logs +pm2 logs claw-applier # tail applier logs +pm2 start claw-searcher # run searcher now +pm2 start claw-applier # run applier now +pm2 stop claw-applier # stop applier mid-run +``` ### 7. Run manually diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index cd262bf..4c7ddc0 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -7,10 +7,12 @@ module.exports = { apps: [ { + // Searcher is triggered by system cron, not PM2 cron_restart. + // PM2 just manages the process — system cron runs: node job_searcher.mjs + // Lockfile prevents parallel runs: if already running, new invocation exits immediately. name: 'claw-searcher', script: 'job_searcher.mjs', - cron_restart: '0 * * * *', // hourly - autorestart: false, // don't restart on exit — it's a one-shot job + autorestart: false, // one-shot — do not restart on exit watch: false, interpreter: 'node', log_file: '/tmp/claw-searcher.log', @@ -19,7 +21,6 @@ module.exports = { { name: 'claw-applier', script: 'job_applier.mjs', - cron_restart: '0 */6 * * *', // every 6 hours autorestart: false, watch: false, interpreter: 'node',