Skip to content

Commit e19e800

Browse files
beacon: explicit serve.js entrypoint for pm2/production
pm2 launches scripts through its own wrapper, so server.js's import.meta.url main-guard never fires and startServer() is never called (process stays up but binds nothing). serve.js imports and calls startServer() unconditionally — robust under pm2, systemd, or direct node.
1 parent 02085eb commit e19e800

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

serve.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Production entrypoint: start the read-only beacon HTTP server.
2+
//
3+
// pm2's launcher does not trigger server.js's `import.meta.url === main`
4+
// guard (it runs the file through its own wrapper), so starting src/server.js
5+
// directly under pm2 loads the module but never calls startServer(). This
6+
// explicit entry guarantees the server boots under any launcher.
7+
//
8+
// PORT=3001 MONGO_DB=nostr pm2 start serve.js --name beacon
9+
import { startServer } from './src/server.js';
10+
11+
startServer().catch((e) => {
12+
console.error('[beacon] failed to start:', e);
13+
process.exit(1);
14+
});

0 commit comments

Comments
 (0)