neex 0.6.66 → 0.6.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,7 +10,6 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
10
10
|
const figures_1 = __importDefault(require("figures"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
12
|
const fs_1 = __importDefault(require("fs"));
|
|
13
|
-
const os_1 = __importDefault(require("os"));
|
|
14
13
|
function addStartCommands(program) {
|
|
15
14
|
let startManager = null;
|
|
16
15
|
// Production start command
|
|
@@ -20,7 +19,7 @@ function addStartCommands(program) {
|
|
|
20
19
|
.option('-d, --dir <directory>', 'Working directory', process.cwd())
|
|
21
20
|
.option('-e, --env <file>', 'Environment file to load', '.env')
|
|
22
21
|
.option('-p, --port <port>', 'Port number', parseInt)
|
|
23
|
-
.option('-w, --workers <count>', 'Number of worker processes
|
|
22
|
+
.option('-w, --workers <count>', 'Number of worker processes', parseInt, 1)
|
|
24
23
|
.option('-v, --verbose', 'Verbose output')
|
|
25
24
|
.option('--watch', 'Watch for changes and restart (development mode)')
|
|
26
25
|
.option('--no-health', 'Disable health check endpoint')
|
|
@@ -89,18 +88,6 @@ function addStartCommands(program) {
|
|
|
89
88
|
// Environment detection
|
|
90
89
|
const isDevelopment = options.watch || process.env.NODE_ENV === 'development';
|
|
91
90
|
const isProduction = !isDevelopment;
|
|
92
|
-
const cpuCount = os_1.default.cpus().length;
|
|
93
|
-
// Smart worker allocation
|
|
94
|
-
let workers = options.workers;
|
|
95
|
-
if (!workers) {
|
|
96
|
-
if (isDevelopment) {
|
|
97
|
-
workers = 1;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// For production, use CPU count but cap at reasonable limit
|
|
101
|
-
workers = Math.min(cpuCount, 4); // Reduced from 8 to 4 for better resource management
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
91
|
const healthCheck = options.health !== false;
|
|
105
92
|
const defaultPort = parseInt(process.env.PORT || '8000');
|
|
106
93
|
const port = options.port || defaultPort;
|
|
@@ -110,14 +97,14 @@ function addStartCommands(program) {
|
|
|
110
97
|
}
|
|
111
98
|
// Startup logging
|
|
112
99
|
const mode = isDevelopment ? 'development' : 'production';
|
|
113
|
-
const clusterInfo = workers > 1 ? ` (${workers} workers)` : '';
|
|
100
|
+
const clusterInfo = options.workers > 1 ? ` (${options.workers} workers)` : '';
|
|
114
101
|
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.green(figures_1.default.play)} Starting ${mode} server${clusterInfo}`, 'info');
|
|
115
102
|
if (options.verbose) {
|
|
116
103
|
logger_manager_js_1.loggerManager.printLine(`File: ${path_1.default.relative(process.cwd(), resolvedFile)}`);
|
|
117
104
|
logger_manager_js_1.loggerManager.printLine(`Working Directory: ${options.dir}`);
|
|
118
105
|
logger_manager_js_1.loggerManager.printLine(`Environment: ${process.env.NODE_ENV}`);
|
|
119
106
|
logger_manager_js_1.loggerManager.printLine(`Port: ${port}`);
|
|
120
|
-
logger_manager_js_1.loggerManager.printLine(`Workers: ${workers}`);
|
|
107
|
+
logger_manager_js_1.loggerManager.printLine(`Workers: ${options.workers}`);
|
|
121
108
|
if (healthCheck) {
|
|
122
109
|
logger_manager_js_1.loggerManager.printLine(`Health Check: http://localhost:${options.healthPort}/health`);
|
|
123
110
|
}
|
|
@@ -126,16 +113,15 @@ function addStartCommands(program) {
|
|
|
126
113
|
file: resolvedFile,
|
|
127
114
|
workingDir: options.dir,
|
|
128
115
|
envFile: options.env,
|
|
129
|
-
port,
|
|
130
|
-
workers,
|
|
131
|
-
memoryLimit:
|
|
132
|
-
logLevel: options.verbose ? '
|
|
133
|
-
color:
|
|
116
|
+
port: options.port,
|
|
117
|
+
workers: options.workers,
|
|
118
|
+
memoryLimit: options.maxMemory,
|
|
119
|
+
logLevel: options.verbose ? 'verbose' : 'info',
|
|
120
|
+
color: true,
|
|
134
121
|
verbose: options.verbose,
|
|
135
122
|
watch: options.watch,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
restartDelay: isProduction ? 1000 : 500,
|
|
123
|
+
maxCrashes: 5,
|
|
124
|
+
restartDelay: 2000,
|
|
139
125
|
healthCheck,
|
|
140
126
|
healthPort: options.healthPort,
|
|
141
127
|
gracefulTimeout: options.gracefulTimeout,
|