Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 75913 invoked from network); 11 Jun 2008 22:34:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Jun 2008 22:34:12 -0000 Received: (qmail 70087 invoked by uid 500); 11 Jun 2008 22:34:14 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 70043 invoked by uid 500); 11 Jun 2008 22:34:14 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 70034 invoked by uid 99); 11 Jun 2008 22:34:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Jun 2008 15:34:14 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Jun 2008 22:33:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0838F23889C1; Wed, 11 Jun 2008 15:33:21 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r666875 - in /geronimo/server/trunk: assemblies/geronimo-boilerplate/src/main/underlay/etc/ framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ Date: Wed, 11 Jun 2008 22:33:20 -0000 To: scm@geronimo.apache.org From: gawor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080611223321.0838F23889C1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gawor Date: Wed Jun 11 15:33:20 2008 New Revision: 666875 URL: http://svn.apache.org/viewvc?rev=666875&view=rev Log: wait-for-server ghsell command (GERONIMO-4115) Added: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy Modified: geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy Modified: geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml?rev=666875&r1=666874&r2=666875&view=diff ============================================================================== --- geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml (original) +++ geronimo/server/trunk/assemblies/geronimo-boilerplate/src/main/underlay/etc/layout.xml Wed Jun 11 15:33:20 2008 @@ -100,6 +100,11 @@ start-client geronimo-commands:start-client + + + wait-for-server + geronimo-commands:wait-for-server + Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy?rev=666875&r1=666874&r2=666875&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy (original) +++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy Wed Jun 11 15:33:20 2008 @@ -58,11 +58,13 @@ PromptReader prompter protected Object doExecute() throws Exception { - return openConnection() + return openConnection(false) } - private ServerConnection openConnection() throws Exception { - io.out.println("Connecting to Geronimo server: ${hostname}:${port}") + protected ServerConnection openConnection(boolean quiet) throws Exception { + if (!quiet) { + io.out.println("Connecting to Geronimo server: ${hostname}:${port}") + } // If the username/password was not configured via cli, then prompt the user for the values if (username == null || password == null) { @@ -90,7 +92,9 @@ variables.parent.set(SERVER_CONNECTION, connection) - io.out.println('Connection established') + if (!quiet) { + io.out.println('Connection established') + } return connection } @@ -99,7 +103,7 @@ def connection = variables.get(SERVER_CONNECTION) if (!connection) { - connection = openConnection() + connection = openConnection(false) } return connection Added: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy?rev=666875&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy (added) +++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/WaitForServerCommand.groovy Wed Jun 11 15:33:20 2008 @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.geronimo.commands + +import org.apache.geronimo.gshell.clp.Option +import org.apache.geronimo.gshell.command.annotation.CommandComponent +import org.apache.geronimo.gshell.command.CommandSupport +import org.apache.geronimo.gshell.command.annotation.Requirement +import org.apache.geronimo.gshell.console.PromptReader +import org.apache.geronimo.deployment.cli.ServerConnection +import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager + +/** + * Wait for a Geronimo server to start. + * + * @version $Rev: 664243 $ $Date: 2008-06-06 22:23:20 -0400 (Fri, 06 Jun 2008) $ + */ +@CommandComponent(id='geronimo-commands:wait-for-server', description='Wait for a Geronimo server to start') +class WaitForServerCommand + extends ConnectCommand +{ + + @Option(name='-t', aliases=['--timeout'], description='Specify the time in seconds to wait while verifying that the server has started. Default 60 seconds') + int timeout = 60 + + protected Object doExecute() throws Exception { + def timer = new Timer(true) + + def timedOut = false + + def timeoutTask + if (timeout > 0) { + timeoutTask = timer.runAfter(timeout * 1000, { + timedOut = true + }) + } + + def started = false + + io.out.println("Waiting for Geronimo server: ${hostname}:${port}") + + def connection + def server + while (!started) { + if (timedOut) { + throw new Exception("Unable to verify if the server was started in the given time") + } + + try { + connection = connect() + server = new ServerProxy(connection.deploymentManager.getJMXConnector()) + } catch (Exception error) { + log.debug("Server query failed; ignoring", error) + Thread.sleep(1000) + continue + } + + started = server.isFullyStarted() + + if (!started) { + Throwable error = server.getLastError() + if (error != null) { + log.debug("Server query failed; ignoring", error) + } + Thread.sleep(1000); + } + } + + timeoutTask?.cancel() + timer.cancel() + + io.out.println("Geronimo server is started") + } + + protected ServerConnection connect() { + def connection = variables.get(SERVER_CONNECTION) + + if (!connection) { + connection = openConnection(true) + } + + return connection + } + +}