neex 0.6.66 → 0.6.68
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,15 @@ function addStartCommands(program) {
|
|
|
110
97
|
}
|
|
111
98
|
// Startup logging
|
|
112
99
|
const mode = isDevelopment ? 'development' : 'production';
|
|
113
|
-
const
|
|
114
|
-
|
|
100
|
+
const workerText = options.workers === 1 ? 'worker' : 'workers';
|
|
101
|
+
const clusterInfo = `(${options.workers} ${workerText})`;
|
|
102
|
+
logger_manager_js_1.loggerManager.printLine(`${chalk_1.default.green(figures_1.default.play)} Starting ${mode} server ${clusterInfo}`, 'info');
|
|
115
103
|
if (options.verbose) {
|
|
116
104
|
logger_manager_js_1.loggerManager.printLine(`File: ${path_1.default.relative(process.cwd(), resolvedFile)}`);
|
|
117
105
|
logger_manager_js_1.loggerManager.printLine(`Working Directory: ${options.dir}`);
|
|
118
106
|
logger_manager_js_1.loggerManager.printLine(`Environment: ${process.env.NODE_ENV}`);
|
|
119
107
|
logger_manager_js_1.loggerManager.printLine(`Port: ${port}`);
|
|
120
|
-
logger_manager_js_1.loggerManager.printLine(`Workers: ${workers}`);
|
|
108
|
+
logger_manager_js_1.loggerManager.printLine(`Workers: ${options.workers}`);
|
|
121
109
|
if (healthCheck) {
|
|
122
110
|
logger_manager_js_1.loggerManager.printLine(`Health Check: http://localhost:${options.healthPort}/health`);
|
|
123
111
|
}
|
|
@@ -126,16 +114,15 @@ function addStartCommands(program) {
|
|
|
126
114
|
file: resolvedFile,
|
|
127
115
|
workingDir: options.dir,
|
|
128
116
|
envFile: options.env,
|
|
129
|
-
port,
|
|
130
|
-
workers,
|
|
131
|
-
memoryLimit:
|
|
132
|
-
logLevel: options.verbose ? '
|
|
133
|
-
color:
|
|
117
|
+
port: options.port,
|
|
118
|
+
workers: options.workers,
|
|
119
|
+
memoryLimit: options.maxMemory,
|
|
120
|
+
logLevel: options.verbose ? 'verbose' : 'info',
|
|
121
|
+
color: true,
|
|
134
122
|
verbose: options.verbose,
|
|
135
123
|
watch: options.watch,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
restartDelay: isProduction ? 1000 : 500,
|
|
124
|
+
maxCrashes: 5,
|
|
125
|
+
restartDelay: 2000,
|
|
139
126
|
healthCheck,
|
|
140
127
|
healthPort: options.healthPort,
|
|
141
128
|
gracefulTimeout: options.gracefulTimeout,
|