@cocreate/server 1.4.0 → 1.5.1

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 CHANGED
@@ -1,3 +1,20 @@
1
+ ## [1.5.1](https://github.com/CoCreate-app/CoCreate-server/compare/v1.5.0...v1.5.1) (2026-07-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump dependencies ([347c732](https://github.com/CoCreate-app/CoCreate-server/commit/347c73285a45f956d489c58470b9e2753f3a7acd))
7
+
8
+ # [1.5.0](https://github.com/CoCreate-app/CoCreate-server/compare/v1.4.0...v1.5.0) (2026-07-17)
9
+
10
+
11
+ ### Features
12
+
13
+ * enhance worker configuration to reserve CPU core for master process ([0a05a51](https://github.com/CoCreate-app/CoCreate-server/commit/0a05a516b4917cafd508a81443855fb5956348bc))
14
+ * replace Metrics with ServerTelemetry for enhanced performance monitoring ([c1de789](https://github.com/CoCreate-app/CoCreate-server/commit/c1de789aa938bc1fa07b95e40728c4fe348ace6b))
15
+ * replace SocketMesh with ServerMesh and add ServerAutoscaler for improved orchestration ([02ac503](https://github.com/CoCreate-app/CoCreate-server/commit/02ac503f709a6d8d4dd680f5d660fc7025cecb1d))
16
+ * set workerId for single Primary process and ensure SocketMesh initialization ([d80084a](https://github.com/CoCreate-app/CoCreate-server/commit/d80084af3e2b72ffa30157be9091d0110302d882))
17
+
1
18
  # [1.4.0](https://github.com/CoCreate-app/CoCreate-server/compare/v1.3.0...v1.4.0) (2026-07-16)
2
19
 
3
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/server",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
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",
@@ -18,9 +18,9 @@
18
18
  "access": "public"
19
19
  },
20
20
  "scripts": {
21
- "start": "npx webpack --config webpack.config.js",
22
- "build": "npx webpack --mode=production --config webpack.config.js",
23
- "dev": "npx webpack --config webpack.config.js --watch"
21
+ "start": "webpack --config webpack.config.js",
22
+ "build": "webpack --mode=production --config webpack.config.js",
23
+ "dev": "webpack --config webpack.config.js --watch"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
@@ -39,6 +39,6 @@
39
39
  "type": "module",
40
40
  "main": "./src/index.js",
41
41
  "dependencies": {
42
- "@cocreate/acme": "^1.3.0"
42
+ "@cocreate/acme": "^1.4.0"
43
43
  }
44
44
  }
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 SocketMesh from '@cocreate/socket-mesh';
24
- import Metrics from '@cocreate/metrics';
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.metrics = null;
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
- this.totalWorkers = parseInt(configuredWorkers, 10) || os.cpus().length;
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 SocketMesh can cleanly read nodes and write startup heartbeats
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 SocketMesh globally. This guarantees both Workers and Primary can safely call "this.mesh.broadcastToPeers"
178
- this.mesh = SocketMesh;
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 resolving environmental context...`);
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 metrics
267
- this.metrics = await Metrics.init(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, () => {