45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
/**
|
|
* PM2 ecosystem — WAJIB memakai nama ecosystem.config.js agar PM2
|
|
* mem-parse `apps` (bukan menjalankan file ini sebagai skrip Node).
|
|
*
|
|
* Jalankan dari root proyek setelah `npm run build`:
|
|
* pm2 start ecosystem.config.js --env production
|
|
*/
|
|
module.exports = {
|
|
apps: [
|
|
{
|
|
/**
|
|
* Fork (1 instance): default aman — satu proses, satu listener PORT, satu
|
|
* pool Prisma ke DB.
|
|
*
|
|
* Cluster mode BISA dipakai: ubah ke `exec_mode: "cluster"` dan
|
|
* `instances: angka` (mis. 2) atau `"max"`. PM2 membagi request antar
|
|
* worker; tiap worker menjalankan `next start` sendiri.
|
|
*
|
|
* Perhatikan: koneksi DB ≈ bertambah per worker (sesuaikan limit Postgres
|
|
* / connection pool Prisma). NextAuth dengan JWT atau session di DB
|
|
* biasanya tidak masalah; hindari mengandalkan state hanya di memory
|
|
* antar request tanpa sticky session. Jika ada EADDRINUSE di PORT,
|
|
* kurangi `instances` atau tetap fork + scale di mesin/proksi lain.
|
|
*/
|
|
name: "setrip",
|
|
cwd: __dirname,
|
|
script: "node_modules/next/dist/bin/next",
|
|
args: "start",
|
|
instances: 1,
|
|
exec_mode: "fork",
|
|
autorestart: true,
|
|
watch: false,
|
|
max_memory_restart: "512M",
|
|
env: {
|
|
NODE_ENV: "production",
|
|
PORT: 3090,
|
|
},
|
|
env_production: {
|
|
NODE_ENV: "production",
|
|
PORT: 3090,
|
|
},
|
|
},
|
|
],
|
|
};
|