How to execute a service once the Grails Server is ready
I have a Grails application which provides dummy webservices for itself. In the real world it could call webservices on another machine, but during development and testing we need be able to access the internal webservice to populate tables. This can't be done during the bootstrap as the internal webserver has not started yet (Grails does this last).
So, I need to be able to detect that Grails has started the webserver, and then run a servi开发者_如何学编程ce to populate tables from the internal webservice.
I don't seem to find anything out there in googleland that appears to help...
One thing that comes to mind is to use a quartz job (with the quartz plugin), you can schedule a job as a one time event and just give it a short delay from when the server is finished starting to when it actually executes it.
class LoadDataJob {
static triggers = {
simple name: 'triggerName', startDelay: 5000 // wait for 5 seconds to run the job
}
def execute(){ /* loading code here */ }
}
精彩评论