querysub 0.231.0 → 0.232.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.231.0",
3
+ "version": "0.232.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",
@@ -233,6 +233,33 @@ const ensureGitSynced = measureWrap(async function ensureGitSynced(config: {
233
233
  let launchesPerService = new Map<string, number>();
234
234
  let lastLaunchedTimePerService = new Map<string, number>();
235
235
 
236
+ async function quickIsOutdated() {
237
+ let machineId = getOwnMachineId();
238
+ let configs = await serviceConfigs.values();
239
+ let relevantConfigs = configs.filter(config => config.machineIds.includes(machineId)).filter(x => x.parameters.deploy);
240
+ let screens = await getScreenState();
241
+ let root = os.homedir() + "/" + SERVICE_FOLDER;
242
+ for (let config of relevantConfigs) {
243
+ let newParametersString = JSON.stringify(config.parameters);
244
+ let matchedCount = config.machineIds.filter(id => id === machineId).length;
245
+ for (let i = 0; i < matchedCount; i++) {
246
+ let screenName = getScreenName({
247
+ serviceKey: config.parameters.key,
248
+ index: i,
249
+ });
250
+ let screen = screens.find(x => x.screenName === screenName);
251
+ if (!screen) return true;
252
+
253
+ let folder = root + config.parameters.key + "-" + i + "/";
254
+ let parameterPath = folder + "/parameters.json";
255
+ if (!fs.existsSync(parameterPath)) return true;
256
+ let prevParameters = await fs.promises.readFile(parameterPath, "utf8");
257
+ if (prevParameters !== newParametersString) return true;
258
+ }
259
+ }
260
+ return false;
261
+ }
262
+
236
263
  const resyncServicesBase = runInSerial(measureWrap(async function resyncServices() {
237
264
  console.log(magenta("Resyncing services"));
238
265
  let machineId = getOwnMachineId();
@@ -415,6 +442,13 @@ export async function machineApplyMain() {
415
442
  await Querysub.hostService("machine-apply");
416
443
  onServiceConfigChange(resyncServices);
417
444
 
445
+ runInfinitePoll(timeInMinute, async () => {
446
+ if (await quickIsOutdated()) {
447
+ console.log(magenta("Likely outdated, resyncing now"));
448
+ await resyncServices();
449
+ }
450
+ });
451
+
418
452
  runInfinitePoll(timeInMinute, async () => {
419
453
  let isRunning = await isPIDRunning(parentPID);
420
454
  if (!isRunning) {
@@ -1,6 +1,3 @@
1
- 7.1) Test with a node script that ignores shutting down.
2
- - in qs-cyoa, so we can just git push
3
-
4
1
  7) More graceful shutdown of services
5
2
  - In some way communicate that we should shut down?
6
3
  - ACTUALLY, we just ctrl+c, which... we might catch right now?