br4chu / docker-compose-maven-plugin

Maven plugin that talks to docker-compose command-line interface
Apache License 2.0
12 stars 4 forks source link

docker-compose logs prior to shutdown when startup timed out #5

Closed sishbi closed 4 years ago

sishbi commented 4 years ago

Hi, I am trying to debug why a container does not start but the docker-compose-maven-plugin shuts down the containers if they do not reach 'stable' state before the timeout which means that I cannot then dump the container logs after the test run. Unfortunately in my environment (i.e. a Jenkins build) I cannot log into the unix console to issue 'docker-compose logs' before the containers shutdown. Would it be possible to add an option to dump the logs from the cluster just before it is shutdown in the case of a timeout? Ideally this dump should go to an optional output file, but dumping to the console is good enough for now.

I can work on a PR if that will help progress this... Thanks, Simon

mjagus commented 4 years ago

Hi Simon, Thank you for you input. This response may come a bit too late, but your issue remains valid nevertheless. I don't really want this plugin to pollute the filesystem with various output/dump files so I'll go with the route of printing the logs to standard output. This should be enough for your use-case as the logs will appear together with logs from Maven and your testing suite, can be correlated with them and be archived by Jenkins.

mjagus commented 4 years ago

Since version 0.8.0 of this plugin it's now possible to provide followLogs parameter to configuration of "up" goal. This will spawn additional process with docker-compose logs -f command with its output redirected to System.out and System.err of JVM process that runs the Maven build. Default value of this parameter is false to maintain backward compatibility, meaning no logs will be captured.

sishbi commented 4 years ago

Thank you for the support. I will test it out and provide feedback