[ 
https://issues.apache.org/jira/browse/CAMEL-25832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18129025#comment-18129025
 ] 

Claus Ibsen commented on CAMEL-25832:
-------------------------------------

PR: https://github.com/apache/camel/pull/28171

* When a run on quarkus, spring-boot or main ends (also camel run pom.xml), its 
<name>.log is kept as the previous run. It has the pid and exit code of the app 
where camel run started it (java -jar, mvn camel:run). With quarkus and 
spring-boot, Maven runs the app in a process of its own, so a failure says 
"Maven ended with exit code N". Exit codes 130/137/143 are reported as the 
signal.
* A <name>.log that a run left behind (such as one that was killed) is kept 
when the next run of that name starts, instead of being deleted.
* Spring Boot logs to <name>.log, as the other runtimes do. An existing Spring 
Boot project gets -Dcamel.main.name, as Quarkus and Camel Main projects already 
do.

Tested end to end with a route that fails at startup, on main, spring-boot and 
quarkus, plus a clean end, a SIGTERM stop, and an existing Spring Boot project.

Found on the way, not changed: with --runtime=main, Camel Main does not log a 
startup failure. Only the JVM prints it, to stderr. So the kept log ends before 
the error. Spring Boot and Quarkus log it.

_Claude Code on behalf of davsclaus_

> camel-jbang - camel run with the quarkus, spring-boot or main runtime keeps 
> no log of the previous run
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-25832
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25832
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 4.24.0
>
>
> CAMEL-25784 keeps the log of a run that ended as 
> {{~/.camel/<name>-previous.log}}, with {{<name>-previous.json}} (pid, when it 
> ended, exit code, signal, failure). {{camel log <name> --previous}} prints 
> it, and the AI tools of the camel-jbang-mcp server read it when the app is 
> gone. This covers {{camel run}} with the default runtime (KameletMain).
> The Maven runtimes keep no log of the previous run. Each of them handles the 
> log of a run in another way ({{Run.java}}):
> * {{--runtime=quarkus}}: the exported project logs to {{~/.camel/<name>.log}} 
> ({{quarkus.log.file.path}}). When camel run ends, the log is deleted (the 
> {{ChildProcess.stopOnExit}} callback in {{runQuarkus}}).
> * {{--runtime=main}}: logs to {{~/.camel/<name>.log}}. The log is deleted 
> when the run starts ({{writeCamelMainRunLogConfig}}) and when it ends 
> ({{runCamelMain}}).
> * An existing Camel Main project: the log is deleted when the next run starts 
> ({{writeCamelMainRunLogConfig}}), not when the run ends.
> * An existing Quarkus project: the same ({{Files.deleteIfExists}} before the 
> Maven command).
> * {{--runtime=spring-boot}}, exported or an existing project: logback logs to 
> {{~/.camel/<pid>.log}} ({{spring-boot-logback.xml}}), with the pid of the 
> Spring Boot JVM. camel run does not delete it. After CAMEL-25784, the next 
> camel run of the default runtime keeps it as the previous run only when the 
> app was killed and its status file is still there. Otherwise it deletes the 
> log after a day, or {{camel dirty --clean}} does.
> So when an app on a Maven runtime fails at startup, {{camel log --previous}} 
> and the tools have nothing to read once camel run has ended, or once the app 
> runs again.
> Proposal: keep the log as the previous run ({{PreviousRun.keep}}) where it is 
> deleted today:
> * in the {{stopOnExit}} callbacks of the export runs (quarkus, main);
> * when an existing project run starts and the log of the last run is still 
> there;
> * for Spring Boot, log to {{<name>.log}} as the other runtimes do, so the log 
> can be kept the same way.
> Notes:
> * The exit code of {{mvn}} is not the exit code of the app: with quarkus:dev 
> and spring-boot:run, the app runs in a child process of Maven. The status 
> file of the app ({{<pid>-status.json}}) has the pid of the app.
> * The name of the run is the {{appName}} that camel run uses for the log file 
> today.
> Follow-up of CAMEL-25784.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to