Fix server startup when launched via PM2.
Use a more reliable main-module check so the HTTP listener starts under process managers. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+4
-2
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import http from 'node:http';
|
import http from 'node:http';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
import { signPayload } from '../lib/signPayload.mjs';
|
import { signPayload } from '../lib/signPayload.mjs';
|
||||||
|
|
||||||
@@ -190,8 +190,10 @@ export function createServer(options = {}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const entryPath = process.argv[1] ? path.resolve(process.argv[1]) : '';
|
||||||
const isMain =
|
const isMain =
|
||||||
process.argv[1] && pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url;
|
entryPath !== '' &&
|
||||||
|
(fileURLToPath(import.meta.url) === entryPath || entryPath.endsWith(`${path.sep}server.mjs`));
|
||||||
|
|
||||||
if (isMain) {
|
if (isMain) {
|
||||||
const privateKeyPem = process.env.LICENSE_PRIVATE_KEY_PEM;
|
const privateKeyPem = process.env.LICENSE_PRIVATE_KEY_PEM;
|
||||||
|
|||||||
Reference in New Issue
Block a user