summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Zelawski <pawel@pzelawski.com>2026-05-23 11:34:15 +0200
committerPawel Zelawski <pawel@pzelawski.com>2026-05-23 11:34:15 +0200
commitca7452469f68d7c36a5d29eb3aca93023d021d1c (patch)
tree3800ef6f08ae0dd0f4aa4d28156f6f937840458c
parent236a87f89e97b55a0c42ae4e3178da9086ebda25 (diff)
fix: ensure server autostarts under pm2 runtimeHEADmaindev
-rw-r--r--src/server/main.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/server/main.ts b/src/server/main.ts
index ecd07fd..2928375 100644
--- a/src/server/main.ts
+++ b/src/server/main.ts
@@ -32,11 +32,6 @@ const defaultConfig: AppConfig = {
nodeEnv: process.env.NODE_ENV ?? 'development',
};
-const isMainModule = () => {
- if (!process.argv[1]) return false;
- return import.meta.url === new URL(`file://${process.argv[1]}`).href;
-};
-
export function createApp(configOverrides: Partial<AppConfig> = {}) {
const config: AppConfig = { ...defaultConfig, ...configOverrides };
const isProduction = config.nodeEnv === 'production';
@@ -310,6 +305,9 @@ export function startServer() {
});
}
-if (isMainModule()) {
+const shouldAutoStart =
+ process.env.NODE_ENV !== 'test' && process.env.VITEST !== 'true';
+
+if (shouldAutoStart) {
startServer();
}