fix
This commit is contained in:
@@ -287,7 +287,7 @@ bun install
|
||||
|
||||
```bash
|
||||
# Start server với PM2
|
||||
pm2 start ecosystem.config.js --env production
|
||||
pm2 start ecosystem.config.cjs --env production
|
||||
|
||||
# Hoặc start trực tiếp
|
||||
pm2 start server.js --name "charging-station-mock" --interpreter bun
|
||||
@@ -368,7 +368,7 @@ sudo certbot renew --dry-run
|
||||
|
||||
| Command | Mô tả |
|
||||
|---------|-------|
|
||||
| `pm2 start ecosystem.config.js` | Start với config file |
|
||||
| `pm2 start ecosystem.config.cjs` | Start với config file |
|
||||
| `pm2 start server.js --name app` | Start với tên custom |
|
||||
| `pm2 list` | Xem danh sách processes |
|
||||
| `pm2 logs [name]` | Xem logs |
|
||||
@@ -386,9 +386,9 @@ sudo certbot renew --dry-run
|
||||
# Cách 1: Environment variable
|
||||
PORT=3200 pm2 start server.js --name "charging-station-mock" --interpreter bun
|
||||
|
||||
# Cách 2: Sửa ecosystem.config.js
|
||||
# Cách 2: Sửa ecosystem.config.cjs
|
||||
# env_production: { PORT: 3200 }
|
||||
pm2 start ecosystem.config.js --env production
|
||||
pm2 start ecosystem.config.cjs --env production
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
21
ecosystem.config.cjs
Normal file
21
ecosystem.config.cjs
Normal file
@@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'charging-station-mock',
|
||||
script: 'server.js',
|
||||
interpreter: 'bun',
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_memory_restart: '500M',
|
||||
env: {
|
||||
NODE_ENV: 'development',
|
||||
PORT: 3100,
|
||||
},
|
||||
env_production: {
|
||||
NODE_ENV: 'production',
|
||||
PORT: 3100,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'charging-station-mock',
|
||||
script: 'server.js',
|
||||
interpreter: 'bun',
|
||||
instances: 1,
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_memory_restart: '500M',
|
||||
env: {
|
||||
NODE_ENV: 'development',
|
||||
PORT: 3100,
|
||||
},
|
||||
env_production: {
|
||||
NODE_ENV: 'production',
|
||||
PORT: 3100,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
1
ecosystem.config.js
Symbolic link
1
ecosystem.config.js
Symbolic link
@@ -0,0 +1 @@
|
||||
ecosystem.config.cjs
|
||||
@@ -1,13 +1,17 @@
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import jsonServer from 'json-server';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const server = jsonServer.create();
|
||||
const router = jsonServer.router(path.join(import.meta.dir, 'db.json'));
|
||||
const router = jsonServer.router(path.join(__dirname, 'db.json'));
|
||||
|
||||
// Serve static files từ folder public (images, etc.)
|
||||
const middlewares = jsonServer.defaults({
|
||||
logger: true,
|
||||
static: path.join(import.meta.dir, 'public'),
|
||||
static: path.join(__dirname, 'public'),
|
||||
});
|
||||
|
||||
const port = process.env.PORT || 3100;
|
||||
|
||||
Reference in New Issue
Block a user