@camunda8/cli 4.3.0-alpha.3 → 4.3.0-alpha.4

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.
@@ -99,6 +99,22 @@ and always leaves the install directory itself in place. Stop the cluster first.
99
99
  If a process does end up orphaned (e.g. the directory was removed outside
100
100
  c8ctl), `cluster stop` terminates it directly using the recorded PID.
101
101
 
102
+ When `cluster start` exits nonzero with surviving Camunda or connector processes,
103
+ the PID record also retains the failed startup outcome. `cluster status` reports
104
+ **`running after failed startup`**, even if the shared health endpoint responds:
105
+ that response does not establish readiness of every physical tenant. Review the
106
+ startup error or c8run logs, then run `c8ctl cluster stop` before retrying. The
107
+ original startup exit code is preserved. Stop clears the record once all recorded
108
+ processes are gone; a successful start replaces any stale failure metadata.
109
+ This also applies when c8run exits successfully but c8ctl's readiness check times
110
+ out: `cluster start` exits 1 and retains the failed startup outcome. Retrying
111
+ while processes survive without an active marker exits 1 without launching a new
112
+ instance or replacing the recovery record.
113
+
114
+ Without a known failed startup, live processes lacking an active marker are
115
+ reported as **`running (untracked)`**, with neutral recovery guidance. Both text
116
+ and JSON status include instructions to stop the surviving processes.
117
+
102
118
  ## How it works
103
119
 
104
120
  1. **Download**: Automatically downloads the correct c8run binary for your platform from the Camunda Download Center
@@ -1644,8 +1644,7 @@ async function startC8Run(config, debug = false, startArgs = []) {
1644
1644
  if (record?.version) {
1645
1645
  logger.info(`Detected running version from the durable PID record: ${record.version}`);
1646
1646
  }
1647
- logger.info('Stop it first with "c8ctl cluster stop".');
1648
- return;
1647
+ throw new Error('Refusing to start while cluster processes survive without an active marker. Stop them first with "c8ctl cluster stop".');
1649
1648
  }
1650
1649
 
1651
1650
  logger.info('Starting Camunda 8 local cluster...');
@@ -1700,7 +1699,7 @@ async function startC8Run(config, debug = false, startArgs = []) {
1700
1699
  // A failed tenant probe leaves healthy engines alive; preserve their identity
1701
1700
  // for stop/status even if the installation directory is subsequently replaced.
1702
1701
  try {
1703
- recordRunningClusterPids(config, { skipEmpty: true });
1702
+ recordRunningClusterPids(config, { skipEmpty: true, startupFailed: true });
1704
1703
  } catch (error) {
1705
1704
  logger.warn(`Could not record surviving cluster processes: ${formatErrorWithCause(error)}. Use "c8ctl cluster stop" while the installation is still present.`);
1706
1705
  }
@@ -1747,6 +1746,13 @@ async function startC8Run(config, debug = false, startArgs = []) {
1747
1746
  writeFileSync(versionFile, config.version);
1748
1747
  printSummary(startupOutput, config.version);
1749
1748
  } else {
1749
+ // Readiness can fail even after c8run exits successfully. Retain the same
1750
+ // recovery handle as a nonzero launcher exit before reporting failure.
1751
+ try {
1752
+ recordRunningClusterPids(config, { skipEmpty: true, startupFailed: true });
1753
+ } catch (error) {
1754
+ logger.warn(`Could not record surviving cluster processes: ${formatErrorWithCause(error)}. Use "c8ctl cluster stop" while the installation is still present.`);
1755
+ }
1750
1756
  logger.error(
1751
1757
  'Cluster failed to start within timeout.',
1752
1758
  );
@@ -2014,11 +2020,11 @@ export function readRunningClusterRecord(cacheDir) {
2014
2020
  } catch {
2015
2021
  return null;
2016
2022
  }
2017
- return { version, pids, signatures };
2023
+ return { version, pids, signatures, ...(parsed.startupFailed === true ? { startupFailed: true } : {}) };
2018
2024
  }
2019
2025
 
2020
2026
  /** Persist the durable running-cluster PID record. */
2021
- export function writeRunningClusterRecord(cacheDir, { version, pids, signatures }) {
2027
+ export function writeRunningClusterRecord(cacheDir, { version, pids, signatures, startupFailed }) {
2022
2028
  mkdirSync(cacheDir, { recursive: true });
2023
2029
  const cleanPids = Array.isArray(pids)
2024
2030
  ? [...new Set(pids.filter((pid) => Number.isInteger(pid) && pid > 0))]
@@ -2043,6 +2049,7 @@ export function writeRunningClusterRecord(cacheDir, { version, pids, signatures
2043
2049
  version: version ?? null,
2044
2050
  pids: cleanPids,
2045
2051
  signatures: cleanSignatures,
2052
+ ...(startupFailed === true ? { startupFailed: true } : {}),
2046
2053
  });
2047
2054
  try {
2048
2055
  writeFileSync(tmpPath, payload);
@@ -2096,7 +2103,7 @@ export function liveRecordedPids(cacheDir) {
2096
2103
  * with a start signature so a later stop/status can tell the recorded process
2097
2104
  * apart from an unrelated one that reused its PID.
2098
2105
  */
2099
- export function recordRunningClusterPids(config, { signatureOf = processStartSignature, skipEmpty = false } = {}) {
2106
+ export function recordRunningClusterPids(config, { signatureOf = processStartSignature, skipEmpty = false, startupFailed = false } = {}) {
2100
2107
  const canFingerprint = platformSupportsProcessSignature();
2101
2108
  const pids = [];
2102
2109
  const signatures = {};
@@ -2125,7 +2132,7 @@ export function recordRunningClusterPids(config, { signatureOf = processStartSig
2125
2132
  }
2126
2133
  }
2127
2134
  if (skipEmpty && pids.length === 0) return 0;
2128
- writeRunningClusterRecord(config.cacheDir, { version: config.version, pids, signatures });
2135
+ writeRunningClusterRecord(config.cacheDir, { version: config.version, pids, signatures, startupFailed });
2129
2136
  return pids.length;
2130
2137
  }
2131
2138
 
@@ -2800,16 +2807,18 @@ export async function clusterStatus(cacheDir) {
2800
2807
  // Health endpoint not reachable
2801
2808
  }
2802
2809
 
2803
- // A cluster process is alive but not tracked by a marker — typically an
2804
- // orphan left after its install dir was replaced/removed (#560).
2810
+ // Only attribute a failure to survivors of that startup, never to unrelated
2811
+ // pidfiles or a shared health endpoint that happens to respond.
2812
+ const startupFailed = record?.startupFailed === true && liveRecordedPids(cacheDir).length > 0;
2813
+ // A missing marker alone does not explain why processes are still running.
2805
2814
  const untracked = !markerExists && processesRunning;
2806
2815
 
2807
- // `untracked` takes precedence over a healthy probe: an orphaned process can
2808
- // still serve the health endpoint while holding its ports, and the operator
2809
- // must be told it is no longer tracked (and how to recover) rather than shown
2810
- // a plain "running". Healthy connection URLs are still surfaced below.
2816
+ // Startup failure and missing-marker diagnostics take precedence over shared
2817
+ // health: a responding endpoint does not establish readiness of every tenant.
2811
2818
  let status;
2812
- if (untracked) {
2819
+ if (startupFailed) {
2820
+ status = 'running after failed startup';
2821
+ } else if (untracked) {
2813
2822
  status = 'running (untracked)';
2814
2823
  } else if (isHealthy) {
2815
2824
  status = 'running';
@@ -2819,17 +2828,19 @@ export async function clusterStatus(cacheDir) {
2819
2828
  status = 'stopped';
2820
2829
  }
2821
2830
 
2831
+ const recovery = startupFailed
2832
+ ? 'Cluster processes are still running after a failed startup. Review the startup error or c8run logs; a responding shared health endpoint does not mean all tenants are ready. Run c8ctl cluster stop before retrying.'
2833
+ : untracked
2834
+ ? 'Cluster processes are still running without an active c8ctl marker. The startup outcome is unknown. Stop them with: c8ctl cluster stop'
2835
+ : undefined;
2836
+
2822
2837
  if (globalThis.c8ctl?.getLogger().mode === 'json') {
2823
- // Machine-readable status must carry the SAME recovery guidance the text
2824
- // renderer prints below for an orphan, otherwise a `--json` consumer sees
2825
- // `running (untracked)` with no actionable instruction (#560).
2838
+ // Machine-readable status carries the same recovery guidance as text.
2826
2839
  logger.json({
2827
2840
  status,
2828
2841
  version,
2829
2842
  urls: isHealthy ? CLUSTER_URLS : undefined,
2830
- recovery: untracked
2831
- ? 'A cluster process is still running but is no longer tracked by c8ctl (its install directory was likely replaced or removed while running). Stop it with: c8ctl cluster stop'
2832
- : undefined,
2843
+ recovery,
2833
2844
  });
2834
2845
  return;
2835
2846
  }
@@ -2857,12 +2868,10 @@ export async function clusterStatus(cacheDir) {
2857
2868
  console.log(' Default credentials: demo / demo');
2858
2869
  }
2859
2870
 
2860
- if (untracked) {
2861
- // Shown even when the orphan is healthy: it is still not tracked by c8ctl.
2871
+ if (recovery) {
2872
+ // Keep text and JSON diagnostics identical even when shared health is UP.
2862
2873
  console.log('');
2863
- console.log(' A cluster process is still running but is no longer tracked by c8ctl');
2864
- console.log(' (its install directory was likely replaced or removed while running).');
2865
- console.log(' Stop it with: c8ctl cluster stop');
2874
+ console.log(` ${recovery}`);
2866
2875
  } else if (!isHealthy) {
2867
2876
  console.log('');
2868
2877
  console.log(' The cluster appears to have been started but is not yet responding.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda8/cli",
3
- "version": "4.3.0-alpha.3",
3
+ "version": "4.3.0-alpha.4",
4
4
  "description": "Camunda 8 CLI - minimal-dependency CLI for Camunda 8 operations",
5
5
  "type": "module",
6
6
  "engines": {