Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log container to STDOUT + List and Stop running services #16851

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Croway
Copy link
Contributor

@Croway Croway commented Jan 17, 2025

  • Use ~/.camel to handle running infra service processes, the infra process start with infra- and have the following structure infra-{serviceName}-{pid}.log
  • Add camel-test-infra-common to camel-jbang-core, this will add testcontainer as a dependency, @davsclaus is it doable? otherwise, I'll refactor the code to use reflection heavily. If you do not see an issue having testcontainer as dependency in camel-jbang-core, I'd move CamelLogConsumer into camel-jbang-core
  • By default the log file will contain the container log, I added a flag --log that output the log to the stdout.
  • Added a stop command, can be used like camel infra stop minio that will delete the file and kill the process (@davsclaus I used a slightly different approach compared to StopProcess).
  • Added a --running parameter to the list command that shows only the running services
$ camel infra run minio
Starting service minio
{
  "accessKey" : "testAccessKey",
  "host" : "localhost",
  "port" : 32835,
  "secretKey" : "testSecretKey"
}
Press any key to stop the execution

$ camel infra list --running
 ALIAS             IMPLEMENTATION  DESCRIPTION
 minio                             MinIO Object Storage, S3 compatible
 
$ camel infra stop minio
Shutting down service minio (PID: 28844)

I'd remove the log Press any key to stop the execution since infra stop is implemented, wdyt?

@Croway Croway force-pushed the log-list-stop-infra-process branch from 1e06f65 to 21a1bae Compare January 17, 2025 15:06
@github-actions github-actions bot added the docs label Jan 17, 2025
@davsclaus
Copy link
Contributor

Maybe use ps or get as we do for camel

camel infra ps

Show just some basic information

camel infra get

Should more details

Then its the same as for camel run

printer().println("Shutting down service " + serviceToStop + " (PID: " + pid + ")");
FileUtil.deleteFile(pidFile);

ProcessHandle.of(Long.valueOf(pid)).ifPresent(ph -> ph.destroyForcibly());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this give test container time to stop the service cleanly, as if you destroy the pid by force then would that not be something like kill -9 ?

@@ -151,6 +151,12 @@
<artifactId>plexus-xml</artifactId>
</dependency>

<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we need to not have this dependency.

You can dynamic download this JAR via that camel maven thing, and we can maybe try set its scope = provided so camel run will not use it normally. And then you can still compile and use its API just that you have downloaded the JAR first.

Otherwise we can also move the command to its own camel jbnag plugin then the dependency can be there (just k8s has kube client JAR etc). But then users need to install this plugin first before they can use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants