geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r561563 - in /geronimo/sandbox/server-gshell-launcher: assemblies/geronimo-jetty6-javaee5-gshell/src/main/assembly/ assemblies/geronimo-jetty6-javaee5-gshell/src/main/config/ modules/geronimo-commands/ modules/geronimo-commands/src/main/gro...
Date Tue, 31 Jul 2007 21:41:21 GMT
Author: jdillon
Date: Tue Jul 31 14:41:20 2007
New Revision: 561563

URL: http://svn.apache.org/viewvc?view=rev&rev=561563
Log:
Update the assembly to keep the gshell libs sep, prepare to pull in the javaee boilerplate
and actually launch the dang server

Modified:
    geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/assembly/bin.xml
    geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/config/gsh-classworlds.conf
    geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/pom.xml
    geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy

Modified: geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/assembly/bin.xml?view=diff&rev=561563&r1=561562&r2=561563
==============================================================================
--- geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/assembly/bin.xml
(original)
+++ geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/assembly/bin.xml
Tue Jul 31 14:41:20 2007
@@ -58,22 +58,11 @@
             <directory>src/main/config</directory>
             <outputDirectory>etc</outputDirectory>
         </fileSet>
-        
-        <fileSet>
-            <directory>target</directory>
-            <outputDirectory>lib</outputDirectory>
-            <includes>
-                <include>gshell-cli-*.jar</include>
-            </includes>
-            <excludes>
-                <exclude>*.pom</exclude>
-            </excludes>
-        </fileSet>
     </fileSets>
     
     <dependencySets>
         <dependencySet>
-            <outputDirectory>lib</outputDirectory>
+            <outputDirectory>lib/gshell</outputDirectory>
             <excludes>
                 <exclude>org.apache.geronimo.gshell:gshell-bootstrap</exclude>
                 <exclude>classworlds:classworlds</exclude>

Modified: geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/config/gsh-classworlds.conf
URL: http://svn.apache.org/viewvc/geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/config/gsh-classworlds.conf?view=diff&rev=561563&r1=561562&r2=561563
==============================================================================
--- geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/config/gsh-classworlds.conf
(original)
+++ geronimo/sandbox/server-gshell-launcher/assemblies/geronimo-jetty6-javaee5-gshell/src/main/config/gsh-classworlds.conf
Tue Jul 31 14:41:20 2007
@@ -25,5 +25,5 @@
 
 [gshell]
 load ${gshell.home}/etc
-load ${gshell.home}/lib/*.jar
+load ${gshell.home}/lib/gshell/*.jar
 

Modified: geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/pom.xml?view=diff&rev=561563&r1=561562&r2=561563
==============================================================================
--- geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/pom.xml (original)
+++ geronimo/sandbox/server-gshell-launcher/modules/geronimo-commands/pom.xml Tue Jul 31 14:41:20
2007
@@ -43,7 +43,6 @@
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy-all</artifactId>
             <version>1.1-beta-2</version>
-            <scope>runtime</scope>
         </dependency>
     </dependencies>
 

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?view=diff&rev=561563&r1=561562&r2=561563
==============================================================================
--- 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
Tue Jul 31 14:41:20 2007
@@ -19,6 +19,7 @@
 
 package org.apache.geronimo.commands
 
+import org.apache.geronimo.gshell.command.Command
 import org.apache.geronimo.gshell.command.CommandSupport
 import org.apache.geronimo.gshell.command.CommandException
 
@@ -32,6 +33,8 @@
 class StartServerCommand
     extends CommandSupport
 {
+    File geronimoHome
+    
     StartServerCommand() {
         super('start-server')
     }
@@ -51,18 +54,269 @@
         // TODO:
         //
         
-        return true
+        return false
     }
 
     protected Object doExecute(Object[] args) throws Exception {
-        assert args
+        assert args != null
         
+        def ant = new AntBuilder()
+        
+        if (!geronimoHome) {
+            geronimoHome = new File(System.properties['gshell.home'])
+        }
+        
+        ant.java(jar: "$geronimoHome/bin/server.jar", dir: geronimoHome, failonerror: true,
fork: true) {
+        }
+        
+        return Command.SUCCESS
+    }
+    
+    /**
+     * Flag to control if we background the server or block Maven execution.
+     */
+    boolean background = false
+    
+    /**
+     * Set the maximum memory for the forked JVM.
+     */
+    String maximumMemory
+
+    /**
+     * The location of the Java Virtual Machine executable to launch the server with.
+     */
+    File javaVirtualMachine
+    
+    /**
+     * Enable quiet mode.
+     */
+    boolean quiet = false
+
+    /**
+     * Enable verbose mode.
+     */
+    boolean verbose = false
+
+    /**
+     * Enable veryverbose mode.
+     */
+    boolean veryverbose = false
+
+    /**
+     * Time in seconds to wait before terminating the forked JVM.
+     */
+    int timeout = -1
+
+    /**
+     * Time in seconds to wait while verifing that the server has started.
+     */
+    int verifyTimeout = -1
+
+    /**
+     * Enable propagation of <tt>org.apache.geronimo.*</tt> and <tt>geronimo.*</tt>
+     * properties from Maven to the forked server process.
+     */
+    boolean propagateGeronimoProperties = true
+    
+    /*
+    void execute() {
         //
-        // TODO:
+        // TODO: Split this entire method up into a few smaller methods
         //
         
-        println 'Doing something fun...'
+        if (install) {
+            installAssembly()
+        }
+        else {
+            log.info('Skipping assembly installation')
+
+            if (!geronimoHome.exists()) {
+                fail("Missing pre-installed assembly directory: $geronimoHome")
+            }
+        }
         
-        return Command.SUCCESS
+        //
+        // TODO: Use ProcessLauncher
+        //
+        
+        // Holds and exceptions that were thrown during execution
+        def errors = []
+        
+        def runner = {
+            try {
+                //
+                // TODO: Do we want to use the repository, and list out the jars here explicity?
+                //
+                
+                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 (maximumMemory) {
+                        node.setAttribute('maximumMemory', maximumMemory)
+                    }
+                    
+                    if (javaVirtualMachine) {
+                        if (!javaVirtualMachine.exists()) {
+                            fail("Java virtual machine is not valid: $javaVirtualMachine")
+                        }
+                        
+                        log.info("Using Java virtual machine: $javaVirtualMachine")
+                        node.setAttribute('jvm', javaVirtualMachine.canonicalPath)
+                    }
+                    
+                    if (logOutput) {
+                        def file = getLogFile()
+                        FileUtils.forceMkdir(file.parentFile)
+                        
+                        log.info("Redirecting output to: $file")
+                        redirector(output: file)
+                    }
+                    
+                    //
+                    // TODO: Make this optional, so it can be disabled if needed for some
reason
+                    //
+                    
+                    // Load the Java programming language agent for JPA if the jar exists
+                    def javaAgentJar = new File(geronimoHome, 'bin/jpa.jar')
+                    if (javaAgentJar.exists()) {
+                        jvmarg(value: "-javaagent:${javaAgentJar.canonicalPath}")
+                    }
+                    else {
+                        log.warn("Missing JPA agent jar: $javaAgentJar")
+                    }
+                    
+                    // Propagate some properties from Maven to the server if enabled
+                    if (propagateGeronimoProperties) {
+                        System.properties.each { name, value ->
+                            if (name == 'geronimo.bootstrap.logging.enabled') {
+                                // Skip this property, never propagate it
+                            }
+                            else if (name.startsWith('org.apache.geronimo') || name.startsWith('geronimo'))
{
+                                log.debug("Propagating: $name=$value")
+                                sysproperty(key: name, value: value)
+                            }
+                        }
+                    }
+                    
+                    //
+                    // TODO: Support using a specific JVM executable
+                    //
+                    
+                    // Set the properties which we pass to the JVM from the startup script
+                    sysproperty(key: 'org.apache.geronimo.base.dir', file: geronimoHome)
+                    sysproperty(key: 'java.io.tmpdir', value: 'var/temp') // Use relative
path
+                    sysproperty(key: 'java.endorsed.dirs', value: prefixSystemPath('java.endorsed.dirs',
new File(geronimoHome, 'lib/endorsed')))
+                    sysproperty(key: 'java.ext.dirs', value: prefixSystemPath('java.ext.dirs',
new File(geronimoHome, 'lib/ext')))
+                    
+                    if (quiet) {
+                        arg(value: '--quiet')
+                    }
+                    else {
+                        arg(value: '--long')
+                    }
+                    
+                    if (verbose) {
+                        arg(value: '--verbose')
+                    }
+                    
+                    if (veryverbose) {
+                        arg(value: '--veryverbose')
+                    }
+                    
+                    if (startModules != null) {
+                        if (startModules.length == 0) {
+                            fail('At least one module name must be configured with startModule')
+                        }
+                        
+                        log.info('Overriding the set of modules to be started')
+                        
+                        arg(value: '--override')
+                        
+                        startModules.each {
+                            arg(value: "$it")
+                        }
+                    }
+                }
+            }
+            catch (Exception e) {
+                errors << e
+            }
+        }
+        
+        log.info('Starting Geronimo server...')
+        
+        // Start the server in a seperate thread
+        def t = new Thread(runner, 'Geronimo Server Runner')
+        def watch = new StopWatch()
+        watch.start()
+        t.start()
+        
+        log.info('Waiting for Geronimo server...')
+        
+        def timer = new Timer(true)
+        def verifyTimedOut = false
+        
+        def timeoutTask = {
+            verifyTimedOut = true
+        }
+
+        if (verifyTimeout > 0) {
+            log.debug("Starting verify timeout task triggers in: $verifyTimeout seconds")
+            timer.schedule(timeoutTask, verifyTimeout * 1000)
+        }
+
+        // Verify server started
+        def server = new ServerProxy(hostname, port, username, password)
+        def started = false
+        
+        while (!started) {
+            if (verifyTimedOut.set) {
+                fail("Unable to verify if the server was started in the given time ($verifyTimeout
seconds)")
+            }
+
+            if (errors) {
+                fail('Failed to start Geronimo server', errors[0])
+            }
+
+            started = server.fullyStarted
+
+            if (!started) {
+                def error = server.lastError
+                if (!error) {
+                    log.debug('Server query failed ignoring', error)
+                }
+
+                Thread.sleep(1000)
+            }
+        }
+
+        // Stop the timer, server should be up now
+        timeoutTask.cancel()
+
+        log.info("Geronimo server started in $watch")
+
+        if (!background) {
+            log.info('Waiting for Geronimo server to shutdown...')
+            t.join()
+        }
+    }
+
+    private String prefixSystemPath(String name, File file) {
+        assert name
+        assert file
+
+        String path = file.path
+        String prop = System.getProperty(name, '')
+        if (prop) {
+            path += File.pathSeparator + prop
+        }
+        
+        return path
     }
+    */
 }



Mime
View raw message