austek / pact-avro-plugin

Pact AVRO Plugin
https://austek.github.io/pact-avro-plugin/
MIT License
8 stars 3 forks source link

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

Closed YOU54F closed 2 months ago

YOU54F commented 2 months ago

See https://github.com/pact-foundation/pact-plugins/issues/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

Effectively this https://github.com/YOU54F/pact-avro-plugin/pull/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 commented 2 months ago

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 commented 2 months ago

It may just need a flush after the println, as was done here: https://github.com/pact-foundation/pact-plugins/blob/main/plugins/protobuf/src/main/kotlin/io/pact/protobuf/plugin/PluginApp.kt#L57

YOU54F commented 2 months ago

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.