Dear Stackoverflow Gurus, I am working with Grails for one of the projects and find this technology very fun to work with. During development of some logic however I need to wait for a long time for a restarting of application in order to test the change that is implemented. This means that after changing single line of code I need to wait for 5+ minutes (because of multiple plugins that are loaded during startup of application) to verify it. Also because of custom logic of some service in project for shutdown I am not be able to use some tools like JRebel or DCEVM. So I am trying to find some custom solution for fast restart without loading the plugins again. Auto recompilation of project is enabled. I find that one method of service (that has custom logic for shutdown) annotated with @PreDestroy annotation from JSR standard is executed during recompilation but the methods annotated with @PostConstruct never do. Which event is triggered after Grails Recompilation during initialization? I found that neither methods from BootStrap, nor GrailsAutoConfiguration classes are called (like 'init', 'onStartup', 'doWithApplicationContext').
Asked
Active
Viewed 51 times
0
-
"I find that one method of service (that has custom logic for shutdown) annotated with @PreDestroy annotation from JSR standard is executed during recompilation but the methods annotated with @PostConstruct never do" - Are you sure that a method marked with `@PreDestroy` is being executed during recompilation? I would expect it to be executed during shutdown before the recompilation happens. – Jeff Scott Brown Jan 05 '23 at 14:50
-
I have tried to reproduce the `@PostContruct` methods not being executed and I can't reproduce that. If you can share a link to a project which demonstrates the problematic behavior I would be happy to investigate. – Jeff Scott Brown Jan 05 '23 at 15:13
-
I have the following code in the service with custom shutdown logic: `@PostConstruct void postConstruct(){ println("Works!") } @PreDestroy void preDestroy() { log.info 'preDestroy :>' }` – Viktor Kalashnykov Jan 05 '23 at 18:12
-
The method with `@PreDestroy` is executed during Auto Recompilation of Grails App. But the one with `@PostConstruct` is never called ( I put breakpoint in the method and it is never called during Auto Recompilation). – Viktor Kalashnykov Jan 05 '23 at 18:15
-
It seems that breakpoints for 'println' calls are never reached (maybe because of specifics of 'println'). But breakpoints for other method with '@PostConstruct' annotation was actually called. So this might be one of possibilities to implement hot reload of classes. – Viktor Kalashnykov Jan 05 '23 at 18:23
-
"So this might be one of possibilities to implement hot reload of classes." - It is possible. I can't reproduce what you are describing but if you file an issue at https://github.com/grails/grails-core/issues describing the behavior and linking to a sample app we can investigate. Thank you for the feedback! – Jeff Scott Brown Jan 05 '23 at 18:58
-
Is it possible that after restart you are not reconnecting the debugging agent? – Jeff Scott Brown Jan 05 '23 at 18:59
-
What do you mean 'after restart'? I am debugging from IDE context and I am trying to test my changes without the restart (by triggering only recompilation of GRails) – Viktor Kalashnykov Jan 05 '23 at 19:51
-
"I am trying to test my changes without the restart" - The question includes "So I am trying to find some custom solution for fast restart". I now think I misunderstood. I am sorry for the confusion. – Jeff Scott Brown Jan 06 '23 at 01:37