diff --git a/bun.config.ts b/bun.config.ts index 10dfcc4..9c0a118 100644 --- a/bun.config.ts +++ b/bun.config.ts @@ -1,5 +1,7 @@ import { buildWithBun } from '@kevisual/code-builder' buildWithBun({ - external: ['playwright', 'better-sqlite3'] + external: ['playwright', 'better-sqlite3'], + target: 'node', + meta: import.meta, }) \ No newline at end of file diff --git a/package.json b/package.json index fdaae1f..e8942ea 100644 --- a/package.json +++ b/package.json @@ -16,13 +16,14 @@ "start": "tsx src/playwright/index.ts", "dev": "tsx watch src/index.ts", "init:browser": "npx playwright install", - "build": "code-builder build", + "build": "bun run bun.config.ts", "browser": "pm2 start start-browser.js --name browser-helper", "cmd": "tsx src/test/cmd.ts ", "init": "pnpm run init:pnpm && pnpm run init:db && pnpm run init:browser", "init:pnpm": "pnpm approve-builds", "init:db": "npx drizzle-kit push", "studio": "npx drizzle-kit studio", + "pm2": "pm2 start dist/app.js --name /root/browser-helper", "drizzle:migrate": "npx drizzle-kit migrate", "drizzle:push": "npx drizzle-kit push" }, diff --git a/src/index.ts b/src/index.ts index 4d636ef..72b8328 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,9 +8,10 @@ app.route({ id: 'auth' }).define(async (ctx) => { // token authentication - + }).addTo(app); -if (import.meta.main) { +const isPm2 = !!process.env.PM2_HOME; +if (import.meta.main || isPm2) { console.log('Starting application...'); app.listen(52000, () => { console.log('Application is running on http://localhost:52000');