This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 4912e28106b CAMEL-18406: camel-jbang - Status command 4912e28106b is described below commit 4912e28106b722262a0fba9a2bd4c970ea01ef70 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Aug 25 09:45:46 2022 +0200 CAMEL-18406: camel-jbang - Status command --- .../modules/ROOT/pages/camel-jbang.adoc | 30 ++++++++-------------- .../apache/camel/dsl/jbang/core/commands/Run.java | 5 ++-- .../core/commands/process/CamelContextStatus.java | 2 +- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc index 2983c4a80e1..c98b9f078fe 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-jbang.adoc @@ -571,17 +571,15 @@ To display the status of the running Camel integrations: [source,bash] ---- -camel get integration -+------+----------+---------+-------+---------+----------+------------+------------+ -| PID | Name | State | Age | Total # | Failed # | Inflight # | Since Last | -+------+----------+---------+-------+---------+----------+------------+------------+ -| 2617 | bar.yaml | started | 1h27m | 5231 | 0 | 0 | 0s | -| 2630 | foo.java | started | 1h27m | 1050 | 0 | 0 | 4s | -+------+----------+---------+-------+---------+----------+------------+------------+ +camel get + PID NAME READY STATE AGE TOTAL FAILED INFLIGHT SINCE-LAST + 38780 routes.yaml 1/1 Started 10s 2 0 0 1s + 38793 dude.java 1/1 Started 9s 6 0 0 0s + 38806 gro.groovy 1/1 Started 8s 3 0 0 0s ---- -TIP: You can use `camel get int` or `camel get context` as a short-hand -command for displaying the integration status as above. +The `camel get` command will default display integrations, which is equivalent to +typing `camel get integrations` or `camel get int`. This displays overall information for every Camel integration, where you can see the total number of messages processed. The column _Since Last_ @@ -593,16 +591,10 @@ You can also see the status of every routes, from all the local Camel integratio [source,bash] ---- camel get route -+------+------------+-----------------------+-------------------------------------+---------+--------+---------+--------+----------+--------+--------+--------+----------+ -| PID | Name | Route ID | From | State | Uptime | Total | Failed | Inflight | Mean | Max | Min | Since | -| | | | | | | # | # | # | (ms) | (ms) | (ms) | Last | -+------+------------+-----------------------+-------------------------------------+---------+--------+---------+--------+----------+--------+--------+--------+----------+ -| 2617 | bar.yaml | route1 | timer://yaml2?period=1000 | started | 1h31m | 5483 | 0 | 0 | 0 | 59 | 0 | 0s | -| 7313 | chuck.yaml | chuck | kamelet://chuck-norris-source | started | 12s | 2 | 0 | 0 | 0 | 1 | 0 | 1s | -| | | chuck-norris-source-1 | timer://chuck?period=10000 | started | 12s | 2 | 0 | 0 | 105 | 133 | 78 | 1s | -| | | log-sink-2 | kamelet://source?routeId=log-sink-2 | started | 12s | 2 | 0 | 0 | 0 | 0 | 0 | 1s | -| 2630 | foo.java | java | timer://java?period=5000 | started | 1h31m | 1101 | 0 | 0 | 0 | 10 | 0 | 1s | -+------+------------+-----------------------+-------------------------------------+---------+--------+---------+--------+----------+--------+--------+--------+----------+ + PID SOURCE ID FROM STATE AGE TOTAL FAILED INFLIGHT MEAN MIN MAX SINCE-LAST + 38911 routes.yaml:18 route1 timer://tick?period=5000 Started 11s 3 0 0 13 0 37 0s + 38924 dude.java:11 java timer://java?period=1000 Started 10s 10 0 0 1 0 5 0s + 38937 gro.groovy groovy timer://groovy?period=1000 Started 8s 8 0 0 1 0 11 0s ---- TIP: Use `camel get --help` to display all the available commands as additional will be added in upcoming releases. diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java index f933ee34aab..35dbc130deb 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java @@ -584,8 +584,8 @@ class Run extends CamelCommand { context.stop(); return; } - // update status file with details from the context console try { + // update status file with details from the context console JsonObject root = new JsonObject(); DevConsole dc = main.getCamelContext().adapt(ExtendedCamelContext.class) .getDevConsoleResolver().resolveDevConsole("context"); @@ -600,7 +600,6 @@ class Run extends CamelCommand { root.put("context", json); json.put("runtime", "camel-jbang"); root.put("routes", json2.get("routes")); - IOHelper.writeText(root.toJson(), statusFile); } } // and health-check readiness @@ -615,6 +614,8 @@ class Run extends CamelCommand { hc.put("ready", ready); hc.put("total", total); root.put("healthChecks", hc); + + IOHelper.writeText(root.toJson(), statusFile); } catch (Throwable e) { // ignore } diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java index a43f274dbd7..7ed706897ef 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java @@ -82,7 +82,7 @@ public class CamelContextStatus extends ProcessBaseCommand { JsonObject root = loadStatus(ph.pid()); if (root != null) { JsonObject hc = (JsonObject) root.get("healthChecks"); - row.ready = hc.getString("ready") + "/" + hc.getString("total"); + row.ready = hc != null ? hc.getString("ready") + "/" + hc.getString("total") : null; JsonObject context = (JsonObject) root.get("context"); row.state = context.getString("state").toLowerCase(Locale.ROOT); Map<String, ?> stats = context.getMap("statistics");