refactor: normalize apply statuses, remove dead code, fix signal handler
- lib/apply/index.mjs: add STATUS_MAP to normalize platform-specific statuses to generic ones (no_button/no_submit/no_modal → skipped_no_apply). Documented all generic statuses for AI/developer reference. - job_applier.mjs: handleResult now handles skipped_no_apply, default case logs + saves instead of silently dropping - lib/linkedin.mjs: remove dead applyLinkedIn() and detectAts(), clean imports (~110 lines removed). Search-only module now. - lib/wellfound.mjs: remove dead applyWellfound(), clean imports. Search-only module now. - lib/lock.mjs: fix async signal handler — shutdown handlers now actually complete before process.exit() - test_linkedin_login.mjs: add try/catch/finally with proper browser cleanup - README: update status table with all current statuses Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
19
lib/lock.mjs
19
lib/lock.mjs
@@ -29,18 +29,21 @@ export function acquireLock(name, dataDir) {
|
||||
|
||||
// Graceful shutdown — call registered cleanup before exiting
|
||||
const shutdownHandlers = [];
|
||||
const shutdown = (code) => async () => {
|
||||
const shutdown = (code) => {
|
||||
console.log(`\n⚠️ ${name}: signal received, shutting down gracefully...`);
|
||||
for (const fn of shutdownHandlers) {
|
||||
try { await fn(); } catch {}
|
||||
}
|
||||
release();
|
||||
process.exit(code);
|
||||
// Run handlers sequentially, then exit
|
||||
(async () => {
|
||||
for (const fn of shutdownHandlers) {
|
||||
try { await fn(); } catch {}
|
||||
}
|
||||
release();
|
||||
process.exit(code);
|
||||
})();
|
||||
};
|
||||
|
||||
process.on('exit', release);
|
||||
process.on('SIGINT', shutdown(130));
|
||||
process.on('SIGTERM', shutdown(143));
|
||||
process.on('SIGINT', () => shutdown(130));
|
||||
process.on('SIGTERM', () => shutdown(143));
|
||||
|
||||
return { release, onShutdown: (fn) => shutdownHandlers.push(fn) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user