geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r567830 - in /geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands: ServerProxy.java StartServerCommand.groovy
Date Mon, 20 Aug 2007 21:11:27 GMT
Author: jdillon
Date: Mon Aug 20 14:11:26 2007
New Revision: 567830

URL: http://svn.apache.org/viewvc?rev=567830&view=rev
Log:
Better trace/debug handling
Show the exit status for ant.java
Add message to user when !background and ctrl-c is hit

Modified:
    geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ServerProxy.java
    geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy

Modified: geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ServerProxy.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ServerProxy.java?rev=567830&r1=567829&r2=567830&view=diff
==============================================================================
--- geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ServerProxy.java
(original)
+++ geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ServerProxy.java
Mon Aug 20 14:11:26 2007
@@ -125,12 +125,26 @@
             }
         }
         catch (IOException e) {
-            log.debug("Connection failure; ignoring", e);
+            String msg = "Connection failure; ignoring";
+            if (log.isTraceEnabled()) {
+                log.trace(msg, e);
+            }
+            else if (log.isDebugEnabled()) {
+                log.debug(msg + ": " + e);
+            }
+            
             fullyStarted = false;
             lastError = e;
         }
         catch (Exception e) {
-            log.debug("Unable to determine if the server is fully started", e);
+            String msg = "Unable to determine if the server is fully started; ignoring";
+            if (log.isTraceEnabled()) {
+                log.trace(msg, e);
+            }
+            else if (log.isDebugEnabled()) {
+                log.debug(msg + ": " + e);
+            }
+            
             fullyStarted = false;
             lastError = e;
         }
@@ -145,19 +159,34 @@
             ObjectName systemInfoQuery = new ObjectName("*:name=ServerInfo,j2eeType=GBean,*");
 
             getConnection();
-           
-            Set set = this.mbeanConnection.queryNames(systemInfoQuery, null);
+
+            Set set = mbeanConnection.queryNames(systemInfoQuery, null);
 
             if (set.size() > 0) {
                 ObjectName found = (ObjectName)set.iterator().next();
-                home = (String)this.mbeanConnection.getAttribute(found, "currentBaseDirectory");
-            } 
-
-        } catch (IOException e) {
-            log.debug("Connection failure; ignoring", e);
+                home = (String)mbeanConnection.getAttribute(found, "currentBaseDirectory");
+            }
+        }
+        catch (IOException e) {
+            String msg = "Connection failure; ignoring";
+            if (log.isTraceEnabled()) {
+                log.trace(msg, e);
+            }
+            else if (log.isDebugEnabled()) {
+                log.debug(msg + ": " + e);
+            }
+            
             lastError = e;
-        } catch (Exception e) {
-            log.debug("Unable to determine if the server home directory", e);
+        }
+        catch (Exception e) {
+            String msg = "Unable to determine if the server is fully started; ignoring";
+            if (log.isTraceEnabled()) {
+                log.trace(msg, e);
+            }
+            else if (log.isDebugEnabled()) {
+                log.debug(msg + ": " + e);
+            }
+            
             lastError = e;
         }
         

Modified: geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy?rev=567830&r1=567829&r2=567830&view=diff
==============================================================================
--- geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy
(original)
+++ geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy
Mon Aug 20 14:11:26 2007
@@ -27,6 +27,8 @@
 import org.apache.commons.cli.OptionBuilder
 import org.apache.commons.cli.Options
 
+import org.apache.tools.ant.ExitStatusException
+
 // Make sure we use our custom builder
 import org.apache.geronimo.commands.AntBuilder
 
@@ -140,6 +142,10 @@
             .withDescription(messages.getMessage('cli.option.background'))
             .create('b'))
         
+        //
+        // TODO: Expose URL, username/password for validation auth
+        //
+        
         return options
     }
     
@@ -256,8 +262,6 @@
     protected Object doExecute(Object[] args) throws Exception {
         assert args != null
         
-        log.info('Starting Geronimo server...')
-        
         def ant = new AntBuilder(log)
         
         if (!geronimoHome) {
@@ -280,63 +284,81 @@
         // TODO: Add rc script muck here...
         //
         
-        def launcher = new ProcessLauncher(name: 'Geronimo Server', background: background)
+        // If we are not backgrounding, then add a nice message for the user when ctrl-c
gets hit
+        if (!background) {
+            addShutdownHook({
+                log.info("Shutting down...")
+            })
+        }
+        
+        def launcher = new ProcessLauncher(log: log, name: 'Geronimo Server', background:
background)
         
         launcher.process = {
-            ant.java(jar: "$geronimoHome/bin/server.jar", dir: geronimoHome, failonerror:
true, fork: true) {
-                def node = current.wrapper
-                
-                if (timeout > 0) {
-                    log.info("Timeout after: ${timeout} seconds")
-                    node.setAttribute('timeout', "${timeout * 1000}")
-                }
-                
-                if (logFile) {
-                    log.info("Redirecting output to: $logFile")
-                    logFile.parentFile.mkdirs()
-                    redirector(output: logFile)
-                }
-                
-                if (javaVirtualMachine) {
-                    if (!javaVirtualMachine.exists()) {
-                        fail("Java virtual machine is not valid: $javaVirtualMachine")
+            try {
+                ant.java(jar: "$geronimoHome/bin/server.jar", dir: geronimoHome, failonerror:
true, fork: true) {
+                    def node = current.wrapper
+                    
+                    if (timeout > 0) {
+                        log.info("Timeout after: ${timeout} seconds")
+                        node.setAttribute('timeout', "${timeout * 1000}")
                     }
                     
-                    log.info("Using Java virtual machine: $javaVirtualMachine")
-                    node.setAttribute('jvm', javaVirtualMachine)
-                }
-                
-                javaFlags.each {
-                    jvmarg(value: it)
-                }
-                
-                properties.each { key, value ->
-                    sysproperty(key: key, value: value)
-                }
-                
-                if (quiet) {
-                    arg(value: '--quiet')
-                }
-                else {
-                    arg(value: '--long')
-                }
-                
-                if (verbose == 1) {
-                    arg(value: '--verbose')
-                }
-                else if (verbose > 1) {
-                    arg(value: '--veryverbose')
-                }
-                
-                if (startModules) {
-                    log.info('Overriding the set of modules to be started')
+                    if (logFile) {
+                        log.info("Redirecting output to: $logFile")
+                        logFile.parentFile.mkdirs()
+                        redirector(output: logFile)
+                    }
                     
-                    arg(value: '--override')
+                    if (javaVirtualMachine) {
+                        if (!javaVirtualMachine.exists()) {
+                            fail("Java virtual machine is not valid: $javaVirtualMachine")
+                        }
+                        
+                        log.info("Using Java virtual machine: $javaVirtualMachine")
+                        node.setAttribute('jvm', javaVirtualMachine)
+                    }
+                    
+                    javaFlags.each {
+                        jvmarg(value: it)
+                    }
+                    
+                    properties.each { key, value ->
+                        sysproperty(key: key, value: value)
+                    }
                     
-                    startModules.each {
-                        arg(value: it)
+                    if (quiet) {
+                        arg(value: '--quiet')
+                    }
+                    else {
+                        arg(value: '--long')
+                    }
+                    
+                    if (verbose == 1) {
+                        arg(value: '--verbose')
+                    }
+                    else if (verbose > 1) {
+                        arg(value: '--veryverbose')
+                    }
+                    
+                    if (startModules) {
+                        log.info('Overriding the set of modules to be started')
+                        
+                        arg(value: '--override')
+                        
+                        startModules.each {
+                            arg(value: it)
+                        }
                     }
                 }
+            }
+            catch (ExitStatusException e) {
+                def tmp = log.&info
+                
+                if (e.status != 0) {
+                    tmp = log.&warn
+                }
+                
+                tmp("Process exited with status: $e.status")
             }
         }
         



Mime
View raw message