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

pact-avro-plugin fails to startup when pact-plugin-driver uses threads, rather than tokio tasks due to LogBack config #42

Closed
YOU54F opened this issue Aug 19, 2024 · 3 comments · Fixed by #45

Comments

@YOU54F
Copy link
Contributor

YOU54F commented Aug 19, 2024

See pact-foundation/pact-plugins#68 for background.

When the pact-plugin-driver uses System threads for managing plugins, the Logback config in the pact-avro-plugin is causing issues.

This is rather than using tokio tasks (using threads was introduced for windows due to hanging plugin tests) and I would like to introduce for macos/linux (due to segfaulting plugin tests in pact-go)

I have tried to narrow it down.

The println for the servers port & serverKey is here

The logback config is here

Removing these bits from the config ( the RollingFileAppender & AsyncAppender ) allow the pact plugin statup message to be picked up

  • <appender name="PLAIN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logs/plugin.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <!-- daily rollover -->
    <fileNamePattern>logs/plugin.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
    <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
    <!-- or whenever the file size reaches 50MB -->
    <maxFileSize>50MB</maxFileSize>
    </timeBasedFileNamingAndTriggeringPolicy>
    <!-- keep 30 days' worth of history -->
    <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder>
    <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%line - %message%n%xException{10}</pattern>
    </encoder>
    </appender>
    <appender name="PLAIN_ASYNCFILE" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="PLAIN_FILE"/>
    <includeCallerData>true</includeCallerData>
    </appender>
  • <appender-ref ref="PLAIN_ASYNCFILE" />

Effectively this YOU54F#2

I've tried removing just the AsyncAppender to no avail, so this means that to get the avro plugin to work on Windows, we need to disable the logging to file, and if we want to fix pact-go plugin behaviour on macos/linux, we will need to switch over to using threads, which means this issue will affect all users.

cc @uglyog - maybe you can shed some light on the world of java loggers

@YOU54F
Copy link
Contributor Author

YOU54F commented Aug 19, 2024

So I got the plugin started on windows and passing tests but it wont close cleanly as its invoked via a batch file. hmm

@rholshausen
Copy link

@YOU54F
Copy link
Contributor Author

YOU54F commented Aug 21, 2024

Thanks Ron, Just tried that out and the same - only picks up the startup message if the file logger is removed

I noted that the plugin app there doesn't use file output

https://github.com/pact-foundation/pact-plugins/blob/main/plugins/protobuf/src/main/resources/logback.xml

FileAppender is documented here

https://logback.qos.ch/manual/appenders.html#FileAppender

and there a few settings in there that may have an impact.

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

Successfully merging a pull request may close this issue.

2 participants