querysub 0.281.0 → 0.282.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.281.0",
3
+ "version": "0.282.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -29,6 +29,18 @@ export function startEdgeNotifier() {
29
29
  }
30
30
  void notifyClients(liveHash, refreshThresholdTime);
31
31
  });
32
+ (async () => {
33
+ await delay(1);
34
+ let { watchOnRollingUpdate } = await import("../deployManager/machineController");
35
+ watchOnRollingUpdate({
36
+ callback: (time) => {
37
+ let duration = Date.now() - time;
38
+ // Refresh 10% earlier, as we don't want clients to refresh RIGHT when the server shutsdown...
39
+ time = Date.now() + duration * 0.9;
40
+ void notifyClients(lastHashServer, time);
41
+ }
42
+ });
43
+ })();
32
44
  }
33
45
 
34
46
  let watchingClientNodes = new Set<string>();
@@ -12,6 +12,7 @@ import { getGitURLLive, setGitRef } from "../4-deploy/git";
12
12
  import os from "os";
13
13
  import { runPromise } from "../functional/runCommand";
14
14
  import { getSyncedController } from "../library-components/SyncedController";
15
+ import { logErrors } from "../errors";
15
16
 
16
17
  const POLL_INTERVAL = timeInMinute * 15;
17
18
 
@@ -35,16 +36,35 @@ export function onServiceConfigChange(callback: () => Promise<void>): () => void
35
36
  serviceConfigChangeWatchers.delete(callback);
36
37
  };
37
38
  }
39
+
40
+
41
+ let rollingUpdateWatchers = new Set<(time: number) => void>();
42
+ export function watchOnRollingUpdate(config: {
43
+ callback: (time: number) => void;
44
+ }) {
45
+ rollingUpdateWatchers.add(config.callback);
46
+ }
38
47
  class OnServiceChangeBase {
39
48
  public async onServiceConfigChange() {
40
49
  await triggerServiceConfigChangeCallbacks();
41
50
  }
51
+
52
+ public async onRollingUpdate(time: number) {
53
+ for (let callback of rollingUpdateWatchers) {
54
+ try {
55
+ callback(time);
56
+ } catch (e) {
57
+ logErrors(e);
58
+ }
59
+ }
60
+ }
42
61
  }
43
62
  export const OnServiceChange = SocketFunction.register(
44
63
  "on-service-change-aa6b4aaa-c325-4112-b2a8-f81c180016a0",
45
64
  () => new OnServiceChangeBase(),
46
65
  () => ({
47
66
  onServiceConfigChange: {},
67
+ onRollingUpdate: {},
48
68
  }),
49
69
  () => ({
50
70
  hooks: [requiresNetworkTrustHook],
@@ -52,6 +72,8 @@ export const OnServiceChange = SocketFunction.register(
52
72
  );
53
73
 
54
74
 
75
+
76
+
55
77
  class MachineControllerBase {
56
78
  // NOTE: We don't need to worry about escaping commands here. YES, the user CAN inject code into the key. But this system is literally for running arbitrary commands, so they could just write a serviceConfig and run anything they want, on all the machines...
57
79
  public async streamScreenOutput(config: {
@@ -23,8 +23,9 @@ The actual http registration isn't working? And our edgeNode file is so messy it
23
23
  - Tracked per serviceId
24
24
  - Update the rolling time, so if we remove the rolling window we kill the old service immediately
25
25
  - Notify when servers are outdated
26
- - In HTTP server, notify users, in the same way we notify for hash updates, that they will need to switch servers
26
+ - After min(5 minute, 10% of rolling window size)
27
27
  - Use the node registration to know the nodeId to talk to, and allow servers to register to get told when they are outdated (and how long before they are shutdown).
28
+ - In HTTP server, notify users, in the same way we notify for hash updates, that they will need to switch servers
28
29
  - Verify this update works with a relatively low rolling update window, ensuring it force refreshes before the server actually restarts.
29
30
 
30
31
  10) Add RAM total, ram % used, cpu count, CPU %, disk size, disk % used to machine info