@avalw/search-worker 2.3.1 → 2.3.3
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/bin/cli.js +2 -8
- package/index.js +5 -21
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* AVALW Search Worker CLI v2.3.
|
|
4
|
+
* AVALW Search Worker CLI v2.3.2
|
|
5
5
|
* Distributed Cache Worker for AVALW Search Network
|
|
6
6
|
*
|
|
7
|
-
* IMPORTANT: From v2.2.0, this worker can ONLY run from Cronos Browser.
|
|
8
|
-
* Running via npx from terminal will be rejected by the server.
|
|
9
|
-
*
|
|
10
7
|
* Features:
|
|
11
8
|
* - Intelligent cache with configurable size limits (100MB - 2GB)
|
|
12
9
|
* - Time-based eviction (1-30 days, default 7)
|
|
@@ -136,12 +133,9 @@ Or set environment variable:
|
|
|
136
133
|
// Print banner
|
|
137
134
|
console.log('');
|
|
138
135
|
console.log('===============================================================');
|
|
139
|
-
console.log(' AVALW SEARCH WORKER v2.3.
|
|
136
|
+
console.log(' AVALW SEARCH WORKER v2.3.2 - Intelligent Distributed Cache');
|
|
140
137
|
console.log('===============================================================');
|
|
141
138
|
console.log('');
|
|
142
|
-
console.log(' NOTE: This worker can ONLY run from Cronos Browser.');
|
|
143
|
-
console.log(' Download Cronos at: https://cronos.avalw.com');
|
|
144
|
-
console.log('');
|
|
145
139
|
|
|
146
140
|
// Print system info
|
|
147
141
|
const cpus = os.cpus();
|
package/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @avalw/search-worker v2.3.
|
|
2
|
+
* @avalw/search-worker v2.3.2
|
|
3
3
|
* Distributed Cache Worker for AVALW Search Network
|
|
4
4
|
*
|
|
5
|
-
* IMPORTANT: From v2.2.0, connections require Cronos Browser authentication.
|
|
6
|
-
* Workers can only run from Cronos Browser, not from terminal/npx.
|
|
7
|
-
*
|
|
8
5
|
* Workers connect to the coordinator via WebSocket and serve as
|
|
9
6
|
* distributed cache nodes, reducing load on AVALW servers.
|
|
10
7
|
*
|
|
@@ -419,9 +416,6 @@ class SearchWorker {
|
|
|
419
416
|
this.dashboardUrl = options.dashboardUrl || 'https://worker.avalw.org';
|
|
420
417
|
this.wsUrl = options.wsUrl || 'wss://worker.avalw.org/ws/cache';
|
|
421
418
|
|
|
422
|
-
// Cronos Browser authentication (required for connection)
|
|
423
|
-
this.cronosKey = options.cronosKey || process.env.CRONOS_WORKER_KEY;
|
|
424
|
-
|
|
425
419
|
// Worker state
|
|
426
420
|
this.workerId = null;
|
|
427
421
|
this.isConnected = false;
|
|
@@ -528,21 +522,16 @@ class SearchWorker {
|
|
|
528
522
|
this.onLog(`Connecting to ${this.wsUrl}...`);
|
|
529
523
|
|
|
530
524
|
try {
|
|
531
|
-
|
|
532
|
-
const wsOptions = {};
|
|
533
|
-
if (this.cronosKey) {
|
|
534
|
-
wsOptions.headers = {
|
|
535
|
-
'X-Cronos-Key': this.cronosKey
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
this.ws = new WebSocket(this.wsUrl, wsOptions);
|
|
525
|
+
this.ws = new WebSocket(this.wsUrl);
|
|
540
526
|
|
|
541
527
|
this.ws.on('open', () => {
|
|
542
528
|
this.onLog('Connected to coordinator');
|
|
543
529
|
this.isConnected = true;
|
|
544
530
|
this.reconnectAttempts = 0;
|
|
545
531
|
|
|
532
|
+
// Authenticate with token
|
|
533
|
+
this._send({ type: 'auth', token: this.workerToken });
|
|
534
|
+
|
|
546
535
|
// Register cached keys
|
|
547
536
|
this._sendCacheRegistry();
|
|
548
537
|
|
|
@@ -759,11 +748,6 @@ class SearchWorker {
|
|
|
759
748
|
'Content-Length': Buffer.byteLength(data)
|
|
760
749
|
};
|
|
761
750
|
|
|
762
|
-
// Add Cronos authentication header if available
|
|
763
|
-
if (this.cronosKey) {
|
|
764
|
-
headers['X-Cronos-Key'] = this.cronosKey;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
751
|
const options = {
|
|
768
752
|
hostname: url.hostname,
|
|
769
753
|
port: url.port || (isHttps ? 443 : 80),
|