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

Jobs do not shutdown at application exit #34

Closed
donald-jackson opened this issue Oct 14, 2015 · 9 comments
Closed

Jobs do not shutdown at application exit #34

donald-jackson opened this issue Oct 14, 2015 · 9 comments

Comments

@donald-jackson
Copy link

When stopping an app (stop-app in development) the Quartz jobs do not stop.

class DomainNameJob {
    static triggers = {
      simple repeatInterval: 5000l // execute job once in 5 seconds
    }

    def execute() {
         // execute job
        log.debug("Domain name job processing");
    }
}

Output from an application here:

| Server running. Browse to http://localhost:8080/Verity
| Application loaded in interactive mode. Type 'stop-app' to shutdown.
| Enter a script name to run. Use TAB for completion: 
2015-10-14 16:46:17,164 [quartzScheduler_Worker-2] DEBUG account.DomainNameJob  - Domain name job processing
2015-10-14 16:46:22,163 [quartzScheduler_Worker-3] DEBUG account.DomainNameJob  - Domain name job processing
2015-10-14 16:46:27,164 [quartzScheduler_Worker-4] DEBUG account.DomainNameJob  - Domain name job processing
grails> 
| Server Stopped
2015-10-14 16:46:32,161 [quartzScheduler_Worker-5] DEBUG account.DomainNameJob  - Domain name job processing
2015-10-14 16:46:37,160 [quartzScheduler_Worker-6] DEBUG account.DomainNameJob  - Domain name job processing
2015-10-14 16:46:42,162 [quartzScheduler_Worker-7] DEBUG account.DomainNameJob  - Domain name job processing

Grails 2.5.1 - latest from branch 1.x.

@kefirfromperm
Copy link
Contributor

Please describe your environment. Grails version, the plugin version, application server.

@rvanderwerf
Copy link
Contributor

I'm confused, I don't think the plugin has responsibility to do this on exit. Many/most people want the jobs to outlive the app, if the app crashes or restarted the jobs should still be in quartz so they can be recovered? Or is this specifically happening for non-persistent or durable jobs?

@donald-jackson
Copy link
Author

@kefirfromperm - apologies. Grails 2.5.1 on Mac OS X 10.10 Java 8 - tomcat 7.0.55.3.

@rvanderwerf - its quite possible, I'm not super familiar with Quartz at this stage - however - if this is the case (the jobs should outlive the application) - how can I detect from within the job that the application is no longer running so it can shut itself down. Using grails run-app / stop-app I would expect it to stop jobs, but I may be wrong. I've also noticed when deploying with Tomcat manager it won't allow the new versions to take over as the old versions will not stop jobs.

@rvanderwerf
Copy link
Contributor

I'd up to the app code to manage this. You have to query jobs and triggers using the quartz API and clean them out if you don't want them anymore. If you do a nice stop, you can add this to your shutdown code as well. Quartz doesn't really provide any auto-management of this out of the box.

@donald-jackson
Copy link
Author

@rvanderwerf OK. Do you have any examples of doing this? I've tried adding blocks of code in the BootStrap destroy methods as well as the onShutdown in plugins config but neither of these methods appear to be triggered at application exit.

@donald-jackson
Copy link
Author

Just checking in here if anyone can assist with this?

@mgkimsal
Copy link

@donald-jackson - did you ever get past this? I'm hitting the same problem.

Maybe I'm misunderstanding the entire purpose of the plugin - it seems to bundle quartz and allow it to autostart. if I'm also then stopping the app, I'd want this to cleanly shut down.

@donald-jackson
Copy link
Author

@mgkimsal unfortunately not, I still have the problem I just use other methods to hard-stop my application now as I'm unable to stop these jobs programmitically or automatically.

davydotcom added a commit to davydotcom/grails-quartz that referenced this issue Mar 28, 2017
…as starting up too early and not spring artifact aware or session bind aware. Also fixes shutdown to properly shutdown before the session gets wiped out from underneath
davydotcom added a commit that referenced this issue Mar 28, 2017
#86)

* Resolves issue #71 , probably #75 and #34. Quartz was starting up too early and not spring artifact aware or session bind aware. Also fixes shutdown to properly shutdown before the session gets wiped out from underneath

* deleting rogue commented code
@davydotcom
Copy link
Contributor

resolved in 2.0.10

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

No branches or pull requests

5 participants