Permalink
Browse files

Fix GRAILS-7885: quit grails console when all windows closed.

The 'console' command now checks every 3 seconds whether any windows are still
open. Once they are all closed, it exits. This saves the user having to do a
Ctrl-C every time (which is not always possible or easy).
  • Loading branch information...
1 parent dd5f996 commit 28da49acabf73566968b8e6053006c931fe1cdb3 @pledbrook pledbrook committed Oct 30, 2012
Showing with 10 additions and 3 deletions.
  1. +10 −3 scripts/Console.groovy
@@ -44,9 +44,16 @@ target(console:"The console implementation target") {
console.run()
def watcher = new GrailsProjectWatcher(projectCompiler, pluginManager)
watcher.start()
- // keep the console running
- while (!InteractiveMode.isActive() && Window.windows) {
- sleep(Integer.MAX_VALUE)
+
+ while (console.frame.visible) {
+ sleep 500
+ }
+
+ // Keep the console running until all windows are closed unless the
+ // interactive console is in use. The interactive console keeps the
+ // VM alive so we don't need to keep this thread running.
+ while (!InteractiveMode.isActive() && Window.windows.any { it.visible }) {
+ sleep 3000
}
} catch (Exception e) {
event("StatusFinal", ["Error starting console: ${e.message}"])

0 comments on commit 28da49a

Please sign in to comment.