@buda-ai/connector 0.1.29 → 0.1.30

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.
Files changed (2) hide show
  1. package/dist/cli.js +22 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -523,7 +523,7 @@ import path2 from "path";
523
523
  // package.json
524
524
  var package_default = {
525
525
  name: "@buda-ai/connector",
526
- version: "0.1.29",
526
+ version: "0.1.30",
527
527
  private: false,
528
528
  type: "module",
529
529
  publishConfig: {
@@ -2790,6 +2790,25 @@ var stopLiveDaemon = async (config, status, configRoot = getConfigRoot(), comman
2790
2790
  await stopUnresponsiveDaemonProcess(status.pid);
2791
2791
  return true;
2792
2792
  };
2793
+ var matchesDaemonIdentity = (config, status) => status.connectorId === config.connectorId && normalizeServerOrigin(status.serverUrl) === normalizeServerOrigin(config.serverUrl) && Number.isSafeInteger(status.pid) && status.pid > 0 && typeof status.instanceId === "string" && status.instanceId.length > 0;
2794
+ var readMatchingPersistedDaemonStatus = async (config, configRoot = getConfigRoot()) => {
2795
+ const status = await readPersistedDaemonStatus(config, configRoot).catch(() => null);
2796
+ return status && matchesDaemonIdentity(config, status) ? status : null;
2797
+ };
2798
+ var stopDaemonForIdentity = async (config, configRoot = getConfigRoot()) => {
2799
+ const liveStatus = await readLiveStatus(config, configRoot);
2800
+ if (liveStatus) {
2801
+ await stopLiveDaemon(config, liveStatus, configRoot);
2802
+ return;
2803
+ }
2804
+ const persistedStatus = await readMatchingPersistedDaemonStatus(config, configRoot);
2805
+ if (!persistedStatus || !isProcessAlive2(persistedStatus.pid)) return;
2806
+ const currentStatus = await readMatchingPersistedDaemonStatus(config, configRoot);
2807
+ if (!currentStatus || currentStatus.pid !== persistedStatus.pid || currentStatus.instanceId !== persistedStatus.instanceId || !isProcessAlive2(currentStatus.pid)) {
2808
+ return;
2809
+ }
2810
+ await stopUnresponsiveDaemonProcess(currentStatus.pid);
2811
+ };
2793
2812
  var shouldRestartUnhealthyDaemonForEnrollment = (status, explicitEnrollment) => explicitEnrollment && status.idle && status.heartbeatHealthy === false;
2794
2813
  var readDaemonLockOwnerPid = async (config) => {
2795
2814
  const lockPath = `${getConnectorDaemonLockTarget(
@@ -2978,9 +2997,7 @@ async function stopLocalConnectorDaemon(connectorId, serverUrl, configRoot = get
2978
2997
  (candidate) => candidate.connectorId === connectorId && normalizeServerOrigin(candidate.serverUrl) === serverOrigin
2979
2998
  );
2980
2999
  if (!config) throw new Error(`Local Connector ${connectorId} was not found`);
2981
- const status = await readLiveStatus(config, configRoot);
2982
- if (!status) return;
2983
- await stopLiveDaemon(config, status, configRoot);
3000
+ await stopDaemonForIdentity(config, configRoot);
2984
3001
  }
2985
3002
  async function stopAllLocalConnectorDaemons(configRoot = getConfigRoot()) {
2986
3003
  const configs = await listDeviceConfigs(configRoot);
@@ -2991,10 +3008,7 @@ async function stopAllLocalConnectorDaemons(configRoot = getConfigRoot()) {
2991
3008
  ${config.connectorId}`, config);
2992
3009
  }
2993
3010
  const results = await Promise.allSettled(
2994
- [...identities.values()].map(async (config) => {
2995
- const status = await readLiveStatus(config, configRoot);
2996
- if (status) await stopLiveDaemon(config, status, configRoot);
2997
- })
3011
+ [...identities.values()].map((config) => stopDaemonForIdentity(config, configRoot))
2998
3012
  );
2999
3013
  const failures = results.filter((result) => result.status === "rejected");
3000
3014
  if (failures.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buda-ai/connector",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "publishConfig": {