@cotal-ai/cli 0.168.0 → 0.170.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/dist/command.d.ts.map +1 -1
- package/dist/command.js +21 -8
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +70 -19
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/app-identity.d.ts.map +1 -1
- package/dist/commands/app-identity.js +14 -5
- package/dist/commands/app-identity.js.map +1 -1
- package/dist/commands/channels.js +2 -2
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +30 -5
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/config.d.ts +1 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +15 -7
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/describe.js +4 -4
- package/dist/commands/describe.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +49 -18
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +81 -10
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/endpoint.d.ts +1 -1
- package/dist/commands/endpoint.d.ts.map +1 -1
- package/dist/commands/endpoint.js +3 -4
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/ext.d.ts +1 -0
- package/dist/commands/ext.d.ts.map +1 -1
- package/dist/commands/ext.js +24 -0
- package/dist/commands/ext.js.map +1 -1
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +5 -0
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/history-clear.js +2 -2
- package/dist/commands/history-clear.js.map +1 -1
- package/dist/commands/history.d.ts +1 -1
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +21 -10
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +113 -28
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/manager-service.d.ts.map +1 -1
- package/dist/commands/manager-service.js +7 -14
- package/dist/commands/manager-service.js.map +1 -1
- package/dist/commands/meshes-add.d.ts.map +1 -1
- package/dist/commands/meshes-add.js +6 -0
- package/dist/commands/meshes-add.js.map +1 -1
- package/dist/commands/meshes.d.ts.map +1 -1
- package/dist/commands/meshes.js +17 -2
- package/dist/commands/meshes.js.map +1 -1
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +19 -4
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/models.d.ts +1 -0
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +11 -3
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/persona.d.ts +1 -0
- package/dist/commands/persona.d.ts.map +1 -1
- package/dist/commands/persona.js +15 -15
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/personas.js +3 -1
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +47 -20
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/service-actions.d.ts.map +1 -1
- package/dist/commands/service-actions.js +15 -8
- package/dist/commands/service-actions.js.map +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +20 -11
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/setup.d.ts +4 -4
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +18 -15
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/space-registration.d.ts.map +1 -1
- package/dist/commands/space-registration.js +37 -12
- package/dist/commands/space-registration.js.map +1 -1
- package/dist/commands/space.d.ts +1 -0
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +13 -2
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn-preview.d.ts.map +1 -1
- package/dist/commands/spawn-preview.js +11 -4
- package/dist/commands/spawn-preview.js.map +1 -1
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +103 -44
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-gone.d.ts +10 -0
- package/dist/commands/stack-gone.d.ts.map +1 -1
- package/dist/commands/stack-gone.js +169 -7
- package/dist/commands/stack-gone.js.map +1 -1
- package/dist/commands/stack-lost-records.js +1 -1
- package/dist/commands/stack-lost-records.js.map +1 -1
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/stack-up.js +13 -6
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/status.d.ts +2 -2
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +244 -93
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +1 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +8 -1
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/team.d.ts.map +1 -1
- package/dist/commands/team.js +4 -1
- package/dist/commands/team.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +35 -10
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts +3 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +117 -25
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/use.d.ts +1 -0
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +6 -0
- package/dist/commands/use.js.map +1 -1
- package/dist/commands/whoami.js +3 -3
- package/dist/commands/whoami.js.map +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +29 -27
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/completion-install.d.ts.map +1 -1
- package/dist/lib/completion-install.js +6 -3
- package/dist/lib/completion-install.js.map +1 -1
- package/dist/lib/confirmation-required.d.ts +14 -0
- package/dist/lib/confirmation-required.d.ts.map +1 -1
- package/dist/lib/confirmation-required.js +13 -0
- package/dist/lib/confirmation-required.js.map +1 -1
- package/dist/lib/connect.d.ts +2 -2
- package/dist/lib/connect.d.ts.map +1 -1
- package/dist/lib/connect.js +6 -4
- package/dist/lib/connect.js.map +1 -1
- package/dist/lib/control.d.ts +8 -0
- package/dist/lib/control.d.ts.map +1 -1
- package/dist/lib/control.js +23 -1
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/controller-restore.d.ts.map +1 -1
- package/dist/lib/controller-restore.js +5 -1
- package/dist/lib/controller-restore.js.map +1 -1
- package/dist/lib/credential-exports.d.ts +1 -0
- package/dist/lib/credential-exports.d.ts.map +1 -1
- package/dist/lib/credential-exports.js +3 -3
- package/dist/lib/credential-exports.js.map +1 -1
- package/dist/lib/delivery-proc.d.ts +2 -0
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/delivery-proc.js +12 -2
- package/dist/lib/delivery-proc.js.map +1 -1
- package/dist/lib/local-process-stop.d.ts.map +1 -1
- package/dist/lib/local-process-stop.js +49 -18
- package/dist/lib/local-process-stop.js.map +1 -1
- package/dist/lib/persona-files.d.ts.map +1 -1
- package/dist/lib/persona-files.js +10 -20
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/restore.js +1 -1
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/self-exec.d.ts +4 -2
- package/dist/lib/self-exec.d.ts.map +1 -1
- package/dist/lib/self-exec.js +22 -11
- package/dist/lib/self-exec.js.map +1 -1
- package/dist/lib/service-preset-target.d.ts.map +1 -1
- package/dist/lib/service-preset-target.js +15 -5
- package/dist/lib/service-preset-target.js.map +1 -1
- package/dist/lib/service-presets.d.ts.map +1 -1
- package/dist/lib/service-presets.js +38 -18
- package/dist/lib/service-presets.js.map +1 -1
- package/dist/lib/service-process.d.ts +10 -0
- package/dist/lib/service-process.d.ts.map +1 -1
- package/dist/lib/service-process.js +108 -3
- package/dist/lib/service-process.js.map +1 -1
- package/dist/lib/stack-journal.d.ts +12 -6
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +73 -18
- package/dist/lib/stack-journal.js.map +1 -1
- package/dist/lib/store-dir.d.ts +4 -2
- package/dist/lib/store-dir.d.ts.map +1 -1
- package/dist/lib/store-dir.js +28 -3
- package/dist/lib/store-dir.js.map +1 -1
- package/dist/lib/update-snapshot.d.ts.map +1 -1
- package/dist/lib/update-snapshot.js +4 -3
- package/dist/lib/update-snapshot.js.map +1 -1
- package/package.json +4 -4
package/dist/commands/up.js
CHANGED
|
@@ -11,7 +11,7 @@ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
|
11
11
|
import { isReachable, dialerFor, DEFAULT_SERVER, DEFAULT_SPACE, SERVICE_AUTHORITY_MAX_BYTES, SERVICE_CALLER_PAYLOAD_FLOOR, CONTRACT_ARTIFACT_MAX_BYTES, MANAGER_START_PAYLOAD_FLOOR, createSpaceAuth, serverConfig, openServerConfig, validateTlsMaterial, credsProblem, mintCreds, mintLifecycleUid, DEV_OWNER, mintConnectionEvictorCreds, mintMembershipObserverCreds, newIdentity, setupSpaceStreams, removeIssuedStoresBeforeRetention, IssuedStoreBeforeRetentionError, IssuedStoreRecreateRefusal, reconcileSpaceMemoryBuckets, membershipStoreDefinition, LEGACY_MEMBERSHIP_MAX_BYTES, MEMBERSHIP_MAX_VALUE_SIZE, ttlBuckets, standaloneConnectOpts, requireBrokerFloor, parseServerVersion, presenceBucket, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry, assertValidChannel, isConcreteChannel, validateChannelConfig, validateChannelDefaults, LEASE_TTL_MS, EpEnvelopeError, mkSecretDir, openPrivateAppend, writeSecretFile, utf16Problem, } from "@cotal-ai/core";
|
|
12
12
|
import { JetStreamApiCodes, jetstreamManager, StorageType } from "@nats-io/jetstream";
|
|
13
13
|
import { Kvm } from "@nats-io/kv";
|
|
14
|
-
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, CommandFailure, codeSpan, commandFailureReport, failureEnvelope, writeEnvelope, isCommandFailure, protectedLocalDirectory, jsonFlag, plainFlag, renderReport, assertSingleSpaceBroker, assertUserAuthInfo, authDir, brokerAddressForDisplay, brokerPolicyPath, getSoleSpaceAuth, soleSpaceOf, getSpaceAuth, hasUserAuthState, listSpaceAccounts, preloadSpaceAccounts, putSpaceAuth, brokerAddressKey, canonicalRoot, rootPathProblem, rootControlProblem, clearCurrent, findMesh, findPreparedSpace, homeCotalDir, getCurrent, loadMeshes, preparedSpaceAt, removePreparedSpace, localMeshesForRoot, keepsRegistration, oneLine, presentationOf, writeResult, connectionEvictorCredsKey, membershipConfigPath, membershipObserverCredsKey, membershipRwCredsKey, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, WEB_CREDS_KIND, webCredsKey, parsePositiveIntegerFlag, recordMesh, retainedLegacyBroker, meshesForRoot, removeMesh, rotateSystemCreds, setAdoptedCurrent, staleSystemCreds, SYSTEM_CREDS_FILES, userAuthStateDir, userAuthSpacesOnDisk, workspaceSecretStore, acquireMaintenanceLock, assertStoreIdentity, assessMaintenanceClaim, assessRestoreClaim, beginOrdinaryResume, bindOrdinaryResumeListener, consumeRetiredMaintenance, markOrdinaryResumeActive, markOrdinaryResumeDegraded, replaceDeadOrdinaryResumeListener, localProcessOwnerStatus, readMaintenanceJournal, rootNamesNoSpace, readMaintenanceResumeDocument, readStoreIdentity, recordOrdinaryResumeManagerCommit, releaseMaintenanceLock, retireOrdinaryResume, settleTokenHandoff, sweepTokenHandoff, writeTokenHandoff, sameStoreIdentity, cutController, readBrokerPolicy, writeBrokerPolicy, brokerAccountResolver, removePidPair, writePidPair, processesNaming, isLoopbackHost, connectUserControlOrThrow, userViewAuth, recordOperationSpace, recordsElsewhereError, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, NATS_PIDFILE, UNTRUSTED_CERTIFICATE, exitCode, canonicalLocalProcessPath, DELIVERY_LOGFILE, terminalWidth, } from "@cotal-ai/workspace";
|
|
14
|
+
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, CommandFailure, codeSpan, commandFailureReport, failureEnvelope, writeEnvelope, isCommandFailure, protectedLocalDirectory, jsonFlag, plainFlag, renderReport, assertSingleSpaceBroker, assertUserAuthInfo, authDir, brokerAddressForDisplay, brokerPolicyPath, getSoleSpaceAuth, soleSpaceOf, getSpaceAuth, hasUserAuthState, listSpaceAccounts, preloadSpaceAccounts, putSpaceAuth, brokerAddressKey, canonicalRoot, rootPathProblem, rootControlProblem, clearCurrent, findMesh, findPreparedSpace, homeCotalDir, legacyStackOtherHome, stackHomeRemedy, getCurrent, loadMeshes, preparedSpaceAt, removePreparedSpace, localMeshesForRoot, keepsRegistration, oneLine, presentationOf, writeResult, connectionEvictorCredsKey, membershipConfigPath, membershipObserverCredsKey, membershipRwCredsKey, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, WEB_CREDS_KIND, webCredsKey, parsePositiveIntegerFlag, recordMesh, retainedLegacyBroker, meshesForRoot, removeMesh, rotateSystemCreds, setAdoptedCurrent, staleSystemCreds, SYSTEM_CREDS_FILES, userAuthStateDir, userAuthSpacesOnDisk, workspaceSecretStore, acquireMaintenanceLock, assertStoreIdentity, assessMaintenanceClaim, assessRestoreClaim, beginOrdinaryResume, bindOrdinaryResumeListener, consumeRetiredMaintenance, markOrdinaryResumeActive, markOrdinaryResumeDegraded, replaceDeadOrdinaryResumeListener, localProcessOwnerStatus, readMaintenanceJournal, rootNamesNoSpace, readMaintenanceResumeDocument, readStoreIdentity, recordOrdinaryResumeManagerCommit, releaseMaintenanceLock, retireOrdinaryResume, settleTokenHandoff, sweepTokenHandoff, writeTokenHandoff, sameStoreIdentity, cutController, readBrokerPolicy, writeBrokerPolicy, brokerAccountResolver, removePidPair, writePidPair, verifyIdentityPin, processesNaming, isLoopbackHost, connectUserControlOrThrow, userViewAuth, recordOperationSpace, recordsElsewhereError, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, NATS_PIDFILE, MANAGER_PIDFILE, DELIVERY_PIDFILE, AUTH_PIDFILE, localProcessPath, UNTRUSTED_CERTIFICATE, exitCode, canonicalLocalProcessPath, DELIVERY_LOGFILE, terminalWidth, } from "@cotal-ai/workspace";
|
|
15
15
|
import { FlagValueRefusal } from "../lib/flag-value-refusal.js";
|
|
16
16
|
import { ensureAuthService, resolveAuthProvider, stopAuthService } from "../lib/auth-proc.js";
|
|
17
17
|
import { resolveSpace } from "../lib/status.js";
|
|
@@ -51,7 +51,7 @@ import { assertUserStackTransport, preflightUserStack } from "./stack-user-auth.
|
|
|
51
51
|
import { stackDown } from "./stack-down.js";
|
|
52
52
|
import { assertControllerCoupling, assertControllerMembersLive, assertControllerResumeEligible, beginControllerResume, bindControllerBroker, controllerAttemptBrokerInstance, currentControllerAttempt, managerResumeAttempt, relaunchCommittedManager, settleControllerResume, startControllerMember, startControllerMembers, } from "../lib/controller-resume.js";
|
|
53
53
|
import { removeRetiredBrokerInstance } from "../lib/controller-restore.js";
|
|
54
|
-
import { acquireStackOperationLock, admittedStackRestore, readStackJournal, refuseControllerCut, STACK_DEFINITION, STACK_ROLES } from "../lib/stack-journal.js";
|
|
54
|
+
import { acquireStackOperationLock, knownStackRecoveryHost, admittedStackRestore, readStackJournal, refuseControllerCut, STACK_DEFINITION, STACK_ROLES } from "../lib/stack-journal.js";
|
|
55
55
|
import { observeServiceProcess, serviceInstances } from "../lib/service-instances.js";
|
|
56
56
|
import { serviceDefinitionStore } from "../lib/service-definitions.js";
|
|
57
57
|
import { MissingFlags } from "../lib/missing-flags.js";
|
|
@@ -294,9 +294,9 @@ export function validateUpArguments(args) {
|
|
|
294
294
|
? "prepare a project folder with `cotal space create <space> --root <dir>`, then run `cotal up` there"
|
|
295
295
|
: `run \`cotal up\` from the project folder ${shellWord(control.project)}` });
|
|
296
296
|
assertUpRootWritable(root);
|
|
297
|
-
// A restore
|
|
298
|
-
if (args.values.restore === undefined
|
|
299
|
-
assertUpStoreWritable(root, typeof args.values["store-dir"] === "string" ? args.values["store-dir"] : undefined);
|
|
297
|
+
// A restore creates its own store. A manifest uses the explicit or default store, not a legacy one.
|
|
298
|
+
if (args.values.restore === undefined)
|
|
299
|
+
assertUpStoreWritable(root, typeof args.values["store-dir"] === "string" ? args.values["store-dir"] : args.values.file === undefined ? undefined : join(root, ".cotal", "nats"));
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
/** Every launch route writes under the root's .cotal first, or makes it when it is missing. A folder
|
|
@@ -316,7 +316,7 @@ function assertUpRootWritable(root) {
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
/** The broker exits when it cannot write its store, naming the cause only in its own log. The store
|
|
319
|
-
* a start here opens, as `--store-dir` names it, as the stack
|
|
319
|
+
* a start here opens, as `--store-dir` names it, as the stack or legacy records name it, or `.cotal/nats`,
|
|
320
320
|
* is refused here, by name, when this account cannot write it. */
|
|
321
321
|
function assertUpStoreWritable(root, storeDir) {
|
|
322
322
|
let recorded;
|
|
@@ -326,7 +326,17 @@ function assertUpStoreWritable(root, storeDir) {
|
|
|
326
326
|
catch {
|
|
327
327
|
recorded = undefined;
|
|
328
328
|
}
|
|
329
|
-
const
|
|
329
|
+
const defaultStore = join(root, ".cotal", "nats");
|
|
330
|
+
if (storeDir === undefined && recorded === undefined) {
|
|
331
|
+
const local = localMeshesForRoot(root);
|
|
332
|
+
recorded = local.length === 1 ? local[0].storeDir : undefined;
|
|
333
|
+
if (recorded === undefined && !existsSync(join(defaultStore, "jetstream"))) {
|
|
334
|
+
const served = lastServedStores(root, defaultStore);
|
|
335
|
+
if (served.length === 1)
|
|
336
|
+
recorded = served[0];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
const problem = storeWriteProblem(storeDir !== undefined ? resolve(storeDir) : recorded ?? defaultStore);
|
|
330
340
|
if (problem)
|
|
331
341
|
throw new CommandFailure("refused", "PERMISSION_DENIED", `${problem.message}; nothing was started or written`, { target: { root, path: problem.path }, remedy: problem.remedy });
|
|
332
342
|
}
|
|
@@ -1418,6 +1428,9 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1418
1428
|
// require its own project root, while dry-run must write nothing to create one.
|
|
1419
1429
|
const previewRoot = values.file && values["dry-run"] && !values.root && inheritedMachineHomeRoot() ? process.cwd() : undefined;
|
|
1420
1430
|
const meshRoot = previewRoot ?? cotalRoot();
|
|
1431
|
+
const ownerHome = legacyStackOtherHome(meshRoot);
|
|
1432
|
+
if (ownerHome !== undefined)
|
|
1433
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "this folder's running stack belongs to another Cotal home; nothing was started", { target: { root: meshRoot, home: ownerHome }, remedy: stackHomeRemedy(ownerHome) });
|
|
1421
1434
|
// A bare start seeds the root's default channels file, so one it would refuse is named here,
|
|
1422
1435
|
// before anything starts; an explicit --channels file was checked with the other flags.
|
|
1423
1436
|
if (!values.file && !values.restore && values.channels === undefined)
|
|
@@ -1616,7 +1629,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1616
1629
|
// that journals, give it `heldLock` and hand it down from here; do not audit by call-site shape.
|
|
1617
1630
|
// The one caller that does NOT pass it is the prepare-failure path above, where the lock has
|
|
1618
1631
|
// genuinely not been taken yet in this frame and the helper is meant to take its own.
|
|
1619
|
-
let startupLock = inheritedLock ?? acquireStackOperationLock(cotalRoot());
|
|
1632
|
+
let startupLock = inheritedLock ?? acquireStackOperationLock(cotalRoot(), values.detach ? undefined : "foreground up");
|
|
1620
1633
|
onAdopt?.(); // from here the release below owns it, inherited or not
|
|
1621
1634
|
const releaseStartupLock = () => {
|
|
1622
1635
|
if (!startupLock)
|
|
@@ -2252,7 +2265,6 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
2252
2265
|
const child = spawnBroker(bin, natsArgs, { cwd: cotalRoot(), stdio: "inherit", detached: process.platform !== "win32" });
|
|
2253
2266
|
let activationFinished = !resumeAttempt;
|
|
2254
2267
|
await recordSpawnedListener(child, listenerStartedAt, boundListener);
|
|
2255
|
-
releaseStartupLock();
|
|
2256
2268
|
child.on("error", (err) => {
|
|
2257
2269
|
console.error(c.red(`Failed to start nats-server: ${err.message}`));
|
|
2258
2270
|
if (!resumeAttempt)
|
|
@@ -2446,6 +2458,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
2446
2458
|
await completeResumeActivation(resumeAttempt, controlPlane !== undefined && authService, !authService ? "normal listener started but the user-auth service is unavailable" : "normal listener started but the control plane is degraded", server, startupLock);
|
|
2447
2459
|
activationFinished = true;
|
|
2448
2460
|
}
|
|
2461
|
+
releaseStartupLock();
|
|
2449
2462
|
await new Promise(() => { });
|
|
2450
2463
|
}
|
|
2451
2464
|
finally {
|
|
@@ -3857,6 +3870,7 @@ async function recordSpawnedListener(child, startedAt, bound) {
|
|
|
3857
3870
|
if (!child.pid)
|
|
3858
3871
|
throw new Error("nats-server spawned with no pid");
|
|
3859
3872
|
try {
|
|
3873
|
+
writeSecretFile(cotalPath("stack-home.json"), JSON.stringify({ home: canonicalRoot(homeCotalDir()) }));
|
|
3860
3874
|
writePidPair(cotalPath(NATS_PIDFILE), child.pid); // #969/#1238: publish the pair by rename, never torn
|
|
3861
3875
|
}
|
|
3862
3876
|
catch (error) {
|
|
@@ -4005,6 +4019,9 @@ async function serveReadyListener(l) {
|
|
|
4005
4019
|
if (svc.userAuth)
|
|
4006
4020
|
recordOurMesh({ space, server, root: cotalRoot(), mode: "user", userAuth: svc.userAuth, ts: new Date().toISOString() }, "refresh", true);
|
|
4007
4021
|
}, l.isStopping);
|
|
4022
|
+
const registered = findMesh(space);
|
|
4023
|
+
if (registered)
|
|
4024
|
+
recordOurMesh(registered, "refresh", true);
|
|
4008
4025
|
seedPersonaAfterUp(cotalRoot(), l.quietBoot);
|
|
4009
4026
|
return { authService: svc.ok, controlPlane };
|
|
4010
4027
|
}
|
|
@@ -4452,7 +4469,15 @@ function recordOurMesh(m, provenance, quietBoot = false) {
|
|
|
4452
4469
|
// (that launch really is the mesh now).
|
|
4453
4470
|
if (provenance === "refresh" && !prior)
|
|
4454
4471
|
throw new Error(`mesh "${m.space}" was removed from the registry while \`cotal up\` refreshed it - not re-recording it from an earlier read`);
|
|
4455
|
-
|
|
4472
|
+
const nativeMembers = [];
|
|
4473
|
+
for (const [role, template] of [["manager", MANAGER_PIDFILE], ["delivery", DELIVERY_PIDFILE], ["auth", AUTH_PIDFILE], ["broker", NATS_PIDFILE]]) {
|
|
4474
|
+
const pin = verifyIdentityPin(role === "broker" ? join(m.root, ".cotal", template) : localProcessPath(template, { root: m.root, space: m.space }));
|
|
4475
|
+
if (pin.kind === "match")
|
|
4476
|
+
nativeMembers.push({ role, process: pin.record });
|
|
4477
|
+
}
|
|
4478
|
+
const nativeHost = nativeMembers.length ? knownStackRecoveryHost() : undefined;
|
|
4479
|
+
const recorded = { ...m, origin, ...(nativeHost !== undefined ? { nativeMembers, nativeHost } : {}) };
|
|
4480
|
+
recordMesh(provenance === "refresh" ? { ...prior, ...recorded } : recorded);
|
|
4456
4481
|
removePreparedSpace(m.space); // started: the registration is its record now
|
|
4457
4482
|
if (!usableCurrent) {
|
|
4458
4483
|
setAdoptedCurrent(m.space);
|