Skip to content

Commit

Permalink
When you close the Grails console window, the command now exits fully…
Browse files Browse the repository at this point in the history
…. In other words, you are dropped back to the command prompt again. Before you had to do a Ctrl-C after exiting the console.

git-svn-id: https://svn.codehaus.org/grails/trunk@7316 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
  • Loading branch information
pledbrook committed Sep 15, 2008
1 parent 9536566 commit 60ff920
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
16 changes: 13 additions & 3 deletions scripts/Bootstrap.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,19 @@ target(shutdownApp:"Shuts down the running Grails application") {
ConfigurationHolder.setConfig(null);
}

monitorCallback = {}
// Flag that determines whether the monitor loop should keep running.
keepMonitoring = true

// Callback invoked by the monitor each time it has checked for changes.
monitorCheckCallback = {}

// Callback invoked by the monitor each time it recompiles the app and
// restarts it.
monitorRecompileCallback = {}

target(monitorApp:"Monitors an application for changes using the PluginManager and reloads changes") {
long lastModified = classesDir.lastModified()
while(true) {
while(keepMonitoring) {
sleep(3500)
try {
pluginManager.checkForChanges()
Expand All @@ -95,11 +103,13 @@ target(monitorApp:"Monitors an application for changes using the PluginManager a
loadPlugins()
loadApp()
configureApp()
monitorCallback()
monitorRecompileCallback()
}

} catch (Exception e) {
println e.message
} finally {
monitorCheckCallback()
}
}
}
Expand Down
16 changes: 13 additions & 3 deletions scripts/Console.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* @since 0.4
*/

import org.codehaus.groovy.grails.commons.GrailsClassUtils as GCU
import groovy.text.SimpleTemplateEngine
import org.codehaus.groovy.grails.support.*

Ant.property(environment:"env")
Expand All @@ -45,13 +43,25 @@ target(console:"The console implementation target") {
createConsole()
try {
console.run()
monitorCallback = {

// On each monitor check, determine whether the console window
// is still open. If not, we set the monitor flag so that its
// thread ends and the script completes.
monitorCheckCallback = {
if (!console.frame.visible) keepMonitoring = false
}

// If the app is recompiled, we close the console and start it
// up again with the new classes.
monitorRecompileCallback = {
println "Exiting console"
console.exit()
createConsole()
println "Restarting console"
console.run()
}

// Start the monitor thread.
monitorApp()
//while(true) { sleep(Long.MAX_VALUE) }
} catch (Exception e) {
Expand Down

0 comments on commit 60ff920

Please sign in to comment.