@cocreate/server 1.4.0 → 1.5.0
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.
- package/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/src/index.js +28 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# [1.5.0](https://github.com/CoCreate-app/CoCreate-server/compare/v1.4.0...v1.5.0) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* enhance worker configuration to reserve CPU core for master process ([0a05a51](https://github.com/CoCreate-app/CoCreate-server/commit/0a05a516b4917cafd508a81443855fb5956348bc))
|
|
7
|
+
* replace Metrics with ServerTelemetry for enhanced performance monitoring ([c1de789](https://github.com/CoCreate-app/CoCreate-server/commit/c1de789aa938bc1fa07b95e40728c4fe348ace6b))
|
|
8
|
+
* replace SocketMesh with ServerMesh and add ServerAutoscaler for improved orchestration ([02ac503](https://github.com/CoCreate-app/CoCreate-server/commit/02ac503f709a6d8d4dd680f5d660fc7025cecb1d))
|
|
9
|
+
* set workerId for single Primary process and ensure SocketMesh initialization ([d80084a](https://github.com/CoCreate-app/CoCreate-server/commit/d80084af3e2b72ffa30157be9091d0110302d882))
|
|
10
|
+
|
|
1
11
|
# [1.4.0](https://github.com/CoCreate-app/CoCreate-server/compare/v1.3.0...v1.4.0) (2026-07-16)
|
|
2
12
|
|
|
3
13
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A dynamic SSL certificate management and generation tool for proxies like NGINX, with a fallback to Node.js SSL termination. It seamlessly integrates HTTP, HTTPS, and ACME protocols to ensure secure, encrypted connections.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ssl-certificate-management",
|
package/src/index.js
CHANGED
|
@@ -20,8 +20,9 @@ import { EventEmitter } from 'node:events';
|
|
|
20
20
|
import Http from 'node:http';
|
|
21
21
|
import Https from 'node:https';
|
|
22
22
|
import Acme from '@cocreate/acme';
|
|
23
|
-
import
|
|
24
|
-
import
|
|
23
|
+
import ServerMesh from '@cocreate/server-mesh';
|
|
24
|
+
import ServerAutoscaler from '@cocreate/server-autoscaler';
|
|
25
|
+
import ServerTelemetry from '@cocreate/server-telemetry';
|
|
25
26
|
|
|
26
27
|
import cluster from 'node:cluster';
|
|
27
28
|
import os from 'node:os';
|
|
@@ -84,12 +85,13 @@ export class CoCreateServer extends EventEmitter {
|
|
|
84
85
|
});
|
|
85
86
|
|
|
86
87
|
this.https = null;
|
|
88
|
+
this.mesh = null;
|
|
89
|
+
this.autoscaler = null;
|
|
87
90
|
this.authenticate = authenticate;
|
|
88
91
|
this.authorize = authorize;
|
|
89
92
|
this.wsManager = null;
|
|
90
|
-
this.mesh = null;
|
|
91
93
|
this.crud = null;
|
|
92
|
-
this.
|
|
94
|
+
this.telemetry = null;
|
|
93
95
|
this.files = null;
|
|
94
96
|
this.loader = null;
|
|
95
97
|
}
|
|
@@ -168,20 +170,34 @@ export class CoCreateServer extends EventEmitter {
|
|
|
168
170
|
let configuredWorkers = config.workers;
|
|
169
171
|
|
|
170
172
|
if (configuredWorkers !== false && configuredWorkers !== 'false') {
|
|
171
|
-
|
|
173
|
+
const parsedWorkers = parseInt(configuredWorkers, 10);
|
|
174
|
+
if (parsedWorkers === -1) {
|
|
175
|
+
// Use total CPU cores minus 1 (minimum of 1) to reserve one core for the master process
|
|
176
|
+
this.totalWorkers = Math.max(1, os.cpus().length - 1);
|
|
177
|
+
} else {
|
|
178
|
+
this.totalWorkers = parsedWorkers || os.cpus().length;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Explicitly set workerId = 1 on the single Primary process if workers configuration specifies no clustering (<= 1)
|
|
183
|
+
if (this.isPrimary && this.totalWorkers <= 1) {
|
|
184
|
+
this.workerId = 1;
|
|
172
185
|
}
|
|
173
186
|
|
|
174
|
-
// DB interface is booted first so that
|
|
187
|
+
// DB interface is booted first so that ServerMesh can cleanly read nodes and write startup heartbeats
|
|
175
188
|
this.crud = await CrudServer.init(this);
|
|
176
189
|
|
|
177
|
-
// Assign the
|
|
178
|
-
this.mesh =
|
|
190
|
+
// Assign the ServerMesh globally. This guarantees both Workers and Primary can safely call "this.mesh.send"
|
|
191
|
+
this.mesh = ServerMesh;
|
|
192
|
+
this.autoscaler = ServerAutoscaler;
|
|
179
193
|
|
|
180
194
|
if (this.isPrimary) {
|
|
181
|
-
console.log(`[@cocreate/server] [PRIMARY] Orchestrator
|
|
195
|
+
console.log(`[@cocreate/server] [PRIMARY] Orchestrator starting...`);
|
|
182
196
|
|
|
183
197
|
this.ip = await getIP();
|
|
184
198
|
this.infrastructure = await resolveInfrastructure(this.id);
|
|
199
|
+
await this.mesh.init(this);
|
|
200
|
+
await this.autoscaler.init(this);
|
|
185
201
|
|
|
186
202
|
if (this.totalWorkers > 1) {
|
|
187
203
|
console.log(`[@cocreate/server] [PRIMARY] Orchestrator running with PID: ${process.pid}`);
|
|
@@ -226,18 +242,12 @@ export class CoCreateServer extends EventEmitter {
|
|
|
226
242
|
});
|
|
227
243
|
});
|
|
228
244
|
|
|
229
|
-
// In clustered mode, only the Primary boots the network tunnels
|
|
230
|
-
await this.mesh.init(this);
|
|
231
|
-
|
|
232
245
|
// In clustered mode, only the Primary exits early. The workers handle the core traffic.
|
|
233
246
|
if (this.totalWorkers > 1) {
|
|
234
247
|
return this;
|
|
235
248
|
}
|
|
236
249
|
}
|
|
237
250
|
}
|
|
238
|
-
|
|
239
|
-
const processLabel = this.isPrimary ? `Primary (${process.pid})` : `Worker ${process.pid} (ID: ${this.workerId})`;
|
|
240
|
-
console.log(`[@cocreate/server] ${processLabel} adopting primary environmental context...`);
|
|
241
251
|
|
|
242
252
|
this.ip = process.env.SERVER_IP || await getIP();
|
|
243
253
|
|
|
@@ -263,13 +273,14 @@ export class CoCreateServer extends EventEmitter {
|
|
|
263
273
|
this.files = FileServer.init(this);
|
|
264
274
|
this.loader = await LazyLoader.init(this);
|
|
265
275
|
|
|
266
|
-
// Initialize performance
|
|
267
|
-
this.
|
|
276
|
+
// Initialize performance telemetry
|
|
277
|
+
this.telemetry = await ServerTelemetry.init(this);
|
|
268
278
|
|
|
269
279
|
// Bind directly to standard web ports (Requires setcap or root privileges)
|
|
270
280
|
const HTTP_PORT = process.env.HTTP_PORT || 80;
|
|
271
281
|
const HTTPS_PORT = process.env.HTTPS_PORT || 443;
|
|
272
282
|
const BIND_IP = process.env.BIND_IP || '0.0.0.0';
|
|
283
|
+
const processLabel = this.isPrimary ? `Primary (${process.pid})` : `Worker ${process.pid} (ID: ${this.workerId})`;
|
|
273
284
|
|
|
274
285
|
if (this.http) {
|
|
275
286
|
this.http.listen(HTTP_PORT, BIND_IP, () => {
|