This commit is contained in:
102
ecosystem.config.js
Normal file
102
ecosystem.config.js
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* PM2 Ecosystem Configuration
|
||||
* Quản lý các process của Sena School Management System
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
apps: [
|
||||
// Main API Server
|
||||
{
|
||||
name: 'sena-api',
|
||||
script: './server.js',
|
||||
instances: 2, // Chạy 2 instances để tận dụng CPU
|
||||
exec_mode: 'cluster',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
PORT: 3000,
|
||||
},
|
||||
env_development: {
|
||||
NODE_ENV: 'development',
|
||||
PORT: 3000,
|
||||
},
|
||||
error_file: './logs/api-error.log',
|
||||
out_file: './logs/api-out.log',
|
||||
log_date_format: 'YYYY-MM-DD HH:mm:ss',
|
||||
merge_logs: true,
|
||||
max_memory_restart: '1G',
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_restarts: 10,
|
||||
min_uptime: '10s',
|
||||
},
|
||||
|
||||
// Database Write Worker
|
||||
{
|
||||
name: 'worker-db-write',
|
||||
script: './workers/databaseWriteWorker.js',
|
||||
instances: 1,
|
||||
exec_mode: 'fork',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
},
|
||||
env_development: {
|
||||
NODE_ENV: 'development',
|
||||
},
|
||||
error_file: './logs/worker-db-write-error.log',
|
||||
out_file: './logs/worker-db-write-out.log',
|
||||
log_date_format: 'YYYY-MM-DD HH:mm:ss',
|
||||
merge_logs: true,
|
||||
max_memory_restart: '512M',
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_restarts: 10,
|
||||
min_uptime: '10s',
|
||||
},
|
||||
|
||||
// Lesson Data Fill Worker
|
||||
{
|
||||
name: 'worker-lesson-fill',
|
||||
script: './workers/lessonDataFillWorker.js',
|
||||
instances: 1,
|
||||
exec_mode: 'fork',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
},
|
||||
env_development: {
|
||||
NODE_ENV: 'development',
|
||||
},
|
||||
error_file: './logs/worker-lesson-fill-error.log',
|
||||
out_file: './logs/worker-lesson-fill-out.log',
|
||||
log_date_format: 'YYYY-MM-DD HH:mm:ss',
|
||||
merge_logs: true,
|
||||
max_memory_restart: '512M',
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_restarts: 10,
|
||||
min_uptime: '10s',
|
||||
},
|
||||
|
||||
// Process Data Worker
|
||||
{
|
||||
name: 'worker-process-data',
|
||||
script: './workers/processDataWorker.js',
|
||||
instances: 2, // Chạy 2 instances để xử lý song song
|
||||
exec_mode: 'fork',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
},
|
||||
env_development: {
|
||||
NODE_ENV: 'development',
|
||||
},
|
||||
error_file: './logs/worker-process-data-error.log',
|
||||
out_file: './logs/worker-process-data-out.log',
|
||||
log_date_format: 'YYYY-MM-DD HH:mm:ss',
|
||||
merge_logs: true,
|
||||
max_memory_restart: '512M',
|
||||
autorestart: true,
|
||||
watch: false,
|
||||
max_restarts: 10,
|
||||
min_uptime: '10s',
|
||||
},
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user