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

Development mode hot-reload for non-REST scenarios #20809

Closed
tlvlp opened this issue Oct 16, 2021 · 11 comments
Closed

Development mode hot-reload for non-REST scenarios #20809

tlvlp opened this issue Oct 16, 2021 · 11 comments
Labels
kind/enhancement New feature or request

Comments

@tlvlp
Copy link

tlvlp commented Oct 16, 2021

Description

Currently Quarkus devmode expects applications to use a limited set of libraries (RESTEasy, SR Reactive Messaging) to work efficiently and have a much faster feedback loop.

But for services that are not using them, and for working on tasks where API calls are not involved, eg. with custom messaging queue implementations or scheduled events, it means that the application needs to go through a complete restart for every change to be able to get feedback.
In these cases the significantly longer start times of devmode is not compensated by fast reloads as there is nothing to trigger them currently.

Implementation ideas

  • There could be an accessible way eg. with a method level runtime annotation, like @HotReloadTrigger that would flag the method to trigger a hot-reload when called.
  • Or alternatively a bit less accessible workaround could be to have a comprehensive guide on how to write wrappers/extensions that would trigger the reload for our existing code.
@tlvlp tlvlp added the kind/enhancement New feature or request label Oct 16, 2021
@stuartwdouglas
Copy link
Member

You can just press 's' in the window to restart the application now. You can also call DevConsoleManager.getHotReplacementContext().doScan(true); if you want to force the scan from your code, but lots of our existing extensions support this already (reactive messaging, gRPC etc.)

@tlvlp
Copy link
Author

tlvlp commented Oct 25, 2021

@stuartwdouglas nice, thanks! For some reason I couldn't and still cannot find reference to this in the documentation.

After testing it a bit, I found that under Intellij I have to send 's' for a single time when running a project with a REST endpoint but when removing all endpoints from it, the 's' has to be sent in twice after each change as the first will not do anything even if left there for minutes.

__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2021-10-25 17:25:33,456 INFO  [com.net.bac.con.lib.LoggerBean] (Quarkus Main Thread) Loading config service lib caches
2021-10-25 17:25:33,762 INFO  [com.net.bac.con.lib.LoggerBean] (Quarkus Main Thread) Config service lib caches loaded in 0.306 seconds
2021-10-25 17:25:33,838 INFO  [io.quarkus] (Quarkus Main Thread) service 1.0.0 on JVM (powered by Quarkus 2.3.1.Final) started in 2.448s. Listening on: http://localhost:8193
2021-10-25 17:25:33,838 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2021-10-25 17:25:33,838 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, micrometer, resteasy-reactive, resteasy-reactive-jackson, scheduler, smallrye-context-propagation, smallrye-fault-tolerance, smallrye-health, smallrye-openapi, swagger-ui, vertx]
s
s
2021-10-25 17:26:17,448 INFO  [io.qua.dep.dev.RuntimeUpdatesProcessor] (Quarkus Terminal Reader) Restarting as requested by the user.
2021-10-25 17:26:17,459 INFO  [io.quarkus] (Quarkus Main Thread) service stopped in 0.008s

@stuartwdouglas
Copy link
Member

Do you have a reproducer? I can't replicate that. Also what environment are you on? I have seen issues like that on Windows before but I thought they were all fixed now.

@tlvlp
Copy link
Author

tlvlp commented Oct 25, 2021

Here are my env's details:

Linux 5.11.0-34-generic
Current Desktop: ubuntu:GNOME
IntelliJ IDEA 2021.2.3 (Ultimate Edition)
Build #IU-212.5457.46, built on October 12, 2021
Runtime version: 11.0.12+7-b1504.40 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

com.redhat.devtools.intellij.quarkus (1.8.0.176)

And here is the reproducer, but is just an empty, freshly generated project with a reactive RESTEasy dependency. It consistently reproduces the same behaviour for me.

@stuartwdouglas
Copy link
Member

Works perfectly for me on Fedora. If there is a problem I would suspect this bit of code here: https://github.com/stuartwdouglas/quarkus/blob/afaca21cc49064a78f79ce14345681065faf9e46/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java#L445

If you have a chance and some free time you could delete that bit, build Quarkus, and see if the problem still exists. This code is responsible for resetting the terminal state if the Quarkus application gets killed, so it is not super important (but the terminal will be left in raw mode if you kill -9 the Quarkus app).

@tlvlp
Copy link
Author

tlvlp commented Oct 26, 2021

I've replaced the whole nested try-catch with a log and tried to build it a few times but all of them have failed.

mvn clean install -Dno-native -Dskip-tests -Dmaven.test.skip=true -e

It seems like it still tries to run the tests for this module for some reason:

Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project io.quarkus:quarkus-resteasy-reactive-servlet-deployment:jar:999-SNAPSHOT: Could not find artifact io.quarkus:quarkus-resteasy-reactive-deployment:jar:tests:999-SNAPSHOT

@stuartwdouglas
Copy link
Member

You need to use -DskipTests rather than -Dmaven.test.skip, because some modules use test-jar dependencies the later won't compile them.

@tlvlp
Copy link
Author

tlvlp commented Oct 26, 2021

Well the build has been going on for more than 2 hours now (running on a relatively strong build machine with an AMD Ryzen 7 4800H + 32GB of RAM and NVMe ssd). Do you have to go through all this to test every single iteration? If not I would appreciate any directions on how you do it normally :)

@stuartwdouglas
Copy link
Member

2h? Is it just downloading dependencies over a slow connection?

I build in ~1 minute using: mvn clean install -T C1 -DskipTests -DskipDocs -Denforcer.skip=true

@tlvlp
Copy link
Author

tlvlp commented Oct 26, 2021

On the build:
Yes I've terminated it now, around 2.5 h and it was still running. I think it was running all tests despite the -DskipTests, that's why I previously tried to run it with -Dmaven.test.skip. Probably skipping the enforcer rules did the trick, thanks :)

On the original issue:
Your suspicion was right. Now the project properly reloads on every single request. Should I raise it as a separate issue?

@stuartwdouglas
Copy link
Member

Yes please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants