querysub 0.212.0 → 0.213.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.212.0",
3
+ "version": "0.213.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",
@@ -18,7 +18,7 @@ import os from "os";
18
18
  import fs from "fs";
19
19
  import { lazy } from "socket-function/src/caching";
20
20
  import { setGitRef } from "../4-deploy/git";
21
- import { blue, magenta } from "socket-function/src/formatting/logColors";
21
+ import { blue, green, magenta } from "socket-function/src/formatting/logColors";
22
22
  import { shutdown } from "../diagnostics/periodic";
23
23
 
24
24
  const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
@@ -126,7 +126,7 @@ const isScreenRunningProcess = measureWrap(async function isScreenRunningProcess
126
126
  let childPids = await getLinuxChildPids(pid);
127
127
  let bashPid = childPids.find(x => x.CMD.includes("bash"));
128
128
  if (!bashPid) {
129
- console.error(`Screen pid ${pid} isn't even running bash? What? We can't check if it's running the process or not, so returning true, which disables crash detection...`);
129
+ console.error(`Screen pid ${pid} isn't even running bash? What? We can't check if it's running the process or not, so returning true, which disables crash detection... is running ${JSON.stringify(childPids)}`);
130
130
  return true;
131
131
  }
132
132
  let bashChildPids = await getLinuxChildPids(bashPid.PID);
@@ -140,7 +140,7 @@ const isScreenRunningProcess = measureWrap(async function isScreenRunningProcess
140
140
  return false;
141
141
  }
142
142
  });
143
- const getScreenState = measureWrap(async function getScreenState(): Promise<{
143
+ const getScreenState = measureWrap(async function getScreenState(populateIsProcessRunning: boolean = true): Promise<{
144
144
  screenName: string;
145
145
  isProcessRunning: boolean;
146
146
  pid: string;
@@ -159,9 +159,11 @@ const getScreenState = measureWrap(async function getScreenState(): Promise<{
159
159
  .filter(x => x.screenName.endsWith(SCREEN_SUFFIX))
160
160
  ;
161
161
 
162
- await Promise.all(screenList.map(async x => {
163
- x.isProcessRunning = await isScreenRunningProcess(x.pid);
164
- }));
162
+ if (populateIsProcessRunning) {
163
+ await Promise.all(screenList.map(async x => {
164
+ x.isProcessRunning = await isScreenRunningProcess(x.pid);
165
+ }));
166
+ }
165
167
 
166
168
  return screenList;
167
169
  });
@@ -257,7 +259,10 @@ const resyncServices = runInSerial(measureWrap(async function resyncServices() {
257
259
  let sameParameters = prevParameters === newParametersString;
258
260
  let screenIsRunning = screenStateMap.get(screenName)?.isProcessRunning;
259
261
 
260
- if (sameParameters && screenIsRunning) continue;
262
+ if (sameParameters && screenIsRunning) {
263
+ console.log(green(`Verified ${magenta(config.serviceId)} is running`));
264
+ continue;
265
+ }
261
266
 
262
267
  console.log(`Resyncing service ${magenta(config.serviceId)}`);
263
268
 
@@ -268,7 +273,7 @@ const resyncServices = runInSerial(measureWrap(async function resyncServices() {
268
273
  command: config.parameters.command,
269
274
  });
270
275
  await delay(2000);
271
- let newScreens = await getScreenState();
276
+ let newScreens = await getScreenState(false);
272
277
  let foundScreen = newScreens.find(x => x.screenName === screenName);
273
278
  if (!foundScreen) {
274
279
  console.error(`Just created screen ${screenName}, but it's not in the list of screens!`);
@@ -279,6 +284,7 @@ const resyncServices = runInSerial(measureWrap(async function resyncServices() {
279
284
  let logs = await runPromise(`${prefix}tmux capture-pane -t ${screenName} -p`);
280
285
  throw new Error(`${logs}\n\nService ${magenta(config.serviceId)} is not running after starting. Trying again in ${formatTime(MACHINE_RESYNC_INTERVAL)}, or on next change. Last logs above.`);
281
286
  }
287
+ console.log(green(`Service ${magenta(config.serviceId)} is verified to be running after starting.`));
282
288
 
283
289
  machineInfo.services[config.serviceId] = {
284
290
  lastLaunchedTime: Date.now(),