lucidsoftware / piezo

Piezo is a set of tools for operating a quartz scheduling cluster.
Apache License 2.0
53 stars 28 forks source link

Guarantees that scheduler gets shut down on SIGTERM #65

Closed gregghz closed 7 years ago

gregghz commented 7 years ago

We use upstart to manager our quartz jobs. Upstart sends SIGTERM to stop the upstart job. Without this change, this terminates the jobs without calling scheduler.shutdown(true). I think this will fix the issues we have of triggers being set to run in the past. If not, it's still a more clean shutdown of quartz.

pauldraper commented 7 years ago

FYI, there's a lot that could be cleaned up if we cared to.

  1. Writes a pid file, but doesn't use it?
  2. Catches and ignores InterruptedException. Usually wrong to ignore it; it means someone wants to stop your thread.
  3. Exits when stdin is closed. (I think?) Most programs only do that if they actually use stdin.
  4. Loops infinitely, consuming a CPU. Should use Thread.sleep(1000) in loop checking Thread.interrupted.
jjudd commented 7 years ago

LGTM. Things could be improved, but this fixes the main problem. I suggest we merge this and then do any other improvement in other PR's.

disaacson commented 7 years ago

@pauldraper most of those sound like misunderstandings. I can explain to you in person if you want. The pid file is used by startup/shutdown scripts. The exiting when stdin is closed mimics how play works. It does not eat up a CPU (misunderstanding about how semaphores work maybe?).