querysub 0.291.0 → 0.293.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/package.json
CHANGED
|
@@ -6,11 +6,10 @@ import { getAllNodeIds, getOwnNodeId } from "../-f-node-discovery/NodeDiscovery"
|
|
|
6
6
|
import { getArchivesBackblazePublic } from "../-a-archives/archivesBackBlaze";
|
|
7
7
|
import { nestArchives } from "../-a-archives/archives";
|
|
8
8
|
import { SocketFunction } from "socket-function/SocketFunction";
|
|
9
|
-
import { runInSerial, runInfinitePoll, runInfinitePollCallAtStart } from "socket-function/src/batching";
|
|
9
|
+
import { delay, runInSerial, runInfinitePoll, runInfinitePollCallAtStart } from "socket-function/src/batching";
|
|
10
10
|
import { compare, compareArray, isNodeTrue, sort, timeInMinute } from "socket-function/src/misc";
|
|
11
11
|
import { cacheLimited, lazy } from "socket-function/src/caching";
|
|
12
12
|
import { canHaveChildren } from "socket-function/src/types";
|
|
13
|
-
import { shutdown } from "../diagnostics/periodic";
|
|
14
13
|
import { hostArchives } from "../-b-authorities/cdnAuthority";
|
|
15
14
|
import { getModuleFromConfig } from "../3-path-functions/pathFunctionLoader";
|
|
16
15
|
import path from "path";
|
|
@@ -41,13 +40,17 @@ const getEdgeNodeConfig = cacheLimited(10000, async (fileName: string): Promise<
|
|
|
41
40
|
return obj;
|
|
42
41
|
});
|
|
43
42
|
let nextNodeNum = 1;
|
|
43
|
+
let registeredNodePaths = new Set<string>();
|
|
44
44
|
function getNextNodePath() {
|
|
45
|
-
|
|
45
|
+
let path = "node" + (nextNodeNum++) + "_" + getOwnNodeId();
|
|
46
|
+
registeredNodePaths.add(path);
|
|
47
|
+
return path;
|
|
46
48
|
}
|
|
47
49
|
function getNodeIdFromPath(path: string) {
|
|
48
50
|
return path.split("_").slice(1).join("_");
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
let edgeShutdown = false;
|
|
51
54
|
|
|
52
55
|
export type EdgeNodesIndex = {
|
|
53
56
|
edgeNodes: EdgeNodeConfig[];
|
|
@@ -84,6 +87,31 @@ export async function registerEdgeNode(config: {
|
|
|
84
87
|
}
|
|
85
88
|
registeredEdgeNode = true;
|
|
86
89
|
let host = config.host;
|
|
90
|
+
await delay(0);
|
|
91
|
+
|
|
92
|
+
const { registerShutdownHandler } = await import("../diagnostics/periodic");
|
|
93
|
+
registerShutdownHandler(async () => {
|
|
94
|
+
edgeShutdown = true;
|
|
95
|
+
console.log(magenta(`Removing node from edge node list due to shutdown`));
|
|
96
|
+
await Promise.all(Array.from(registeredNodePaths).map(async nodePath => {
|
|
97
|
+
await edgeNodeStorage.del(nodePath);
|
|
98
|
+
}));
|
|
99
|
+
await updateEdgeNodesFile();
|
|
100
|
+
});
|
|
101
|
+
const { watchOnRollingUpdate } = await import("../deployManager/machineController");
|
|
102
|
+
watchOnRollingUpdate({
|
|
103
|
+
callback: async (time) => {
|
|
104
|
+
let duration = time - Date.now();
|
|
105
|
+
// Wait a bit to remove ourself from the edge node list
|
|
106
|
+
void delay(duration * 0.2).finally(async () => {
|
|
107
|
+
console.log(magenta(`Removing node from edge node list due to rolling update at ${new Date().toLocaleString()}`));
|
|
108
|
+
await Promise.all(Array.from(registeredNodePaths).map(async nodePath => {
|
|
109
|
+
await edgeNodeStorage.del(nodePath);
|
|
110
|
+
}));
|
|
111
|
+
await updateEdgeNodesFile();
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
});
|
|
87
115
|
|
|
88
116
|
await waitForFirstTimeSync();
|
|
89
117
|
|
|
@@ -193,6 +221,7 @@ const startUpdateLoop = lazy(async () => {
|
|
|
193
221
|
});
|
|
194
222
|
|
|
195
223
|
async function updateLoop() {
|
|
224
|
+
if (edgeShutdown) return;
|
|
196
225
|
await runEdgeNodesAliveCheck();
|
|
197
226
|
await updateEdgeNodesFile();
|
|
198
227
|
}
|
|
@@ -261,6 +290,7 @@ async function updateEdgeNodesFile() {
|
|
|
261
290
|
newEdgeNodeIndex.edgeNodes.push(edgeNodeConfig);
|
|
262
291
|
}
|
|
263
292
|
|
|
293
|
+
console.log(magenta(`Updating ${edgeNodeIndexFile} with ${JSON.stringify(newEdgeNodeIndex)}`));
|
|
264
294
|
await edgeNodeStorage.set(edgeNodeIndexFile, Buffer.from(JSON.stringify(newEdgeNodeIndex)));
|
|
265
295
|
}
|
|
266
296
|
|
|
@@ -4,7 +4,7 @@ Hmm... our cyoa servers are dying very fast... why?
|
|
|
4
4
|
- Add rollingWindow to the definition
|
|
5
5
|
- Set for public facing services (but not for scripts)
|
|
6
6
|
- PathValueServer - 10 minutes
|
|
7
|
-
- FunctionRunner -
|
|
7
|
+
- FunctionRunner - CANNOT use rolling
|
|
8
8
|
- HTTP - 4 hours
|
|
9
9
|
- Boostrapper - NO rolling
|
|
10
10
|
- gc/join - NO rolling
|