Make the classes that get started by jsvc implement Daemon. Set the daemon version centrally in the pom
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dcc288c8 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dcc288c8 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dcc288c8 Branch: refs/heads/ui-vpc-redesign Commit: dcc288c8bebe3dae2511c062be29eee86310e18b Parents: c211818 Author: Hugo Trippaers <[email protected]> Authored: Mon May 13 16:53:27 2013 +0200 Committer: Hugo Trippaers <[email protected]> Committed: Mon May 13 16:53:27 2013 +0200 ---------------------------------------------------------------------- agent/pom.xml | 5 +++++ agent/src/com/cloud/agent/AgentShell.java | 19 +++++++++++++++++-- pom.xml | 1 + usage/pom.xml | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcc288c8/agent/pom.xml ---------------------------------------------------------------------- diff --git a/agent/pom.xml b/agent/pom.xml index 0f44c1a..c2b1502 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -36,6 +36,11 @@ <artifactId>cloud-utils</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>commons-daemon</groupId> + <artifactId>commons-daemon</artifactId> + <version>${cs.daemon.version}</version> + </dependency> </dependencies> <build> <defaultGoal>install</defaultGoal> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcc288c8/agent/src/com/cloud/agent/AgentShell.java ---------------------------------------------------------------------- diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java index 73b3950..3796f3b 100644 --- a/agent/src/com/cloud/agent/AgentShell.java +++ b/agent/src/com/cloud/agent/AgentShell.java @@ -38,6 +38,9 @@ import java.util.UUID; import javax.naming.ConfigurationException; +import org.apache.commons.daemon.Daemon; +import org.apache.commons.daemon.DaemonContext; +import org.apache.commons.daemon.DaemonInitException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; import org.apache.commons.httpclient.methods.GetMethod; @@ -58,7 +61,7 @@ import com.cloud.utils.backoff.impl.ConstantTimeBackoff; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; -public class AgentShell implements IAgentShell { +public class AgentShell implements IAgentShell, Daemon { private static final Logger s_logger = Logger.getLogger(AgentShell.class .getName()); private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager(); @@ -376,7 +379,17 @@ public class AgentShell implements IAgentShell { return true; } - + + @Override + public void init(DaemonContext dc) throws DaemonInitException { + s_logger.debug("Initializing AgentShell from JSVC"); + try { + init(dc.getArguments()); + } catch (ConfigurationException ex) { + throw new DaemonInitException("Initialization failed", ex); + } + } + public void init(String[] args) throws ConfigurationException { // PropertiesUtil is used both in management server and agent packages, @@ -629,6 +642,7 @@ public class AgentShell implements IAgentShell { public static void main(String[] args) { try { + s_logger.debug("Initializing AgentShell from main"); AgentShell shell = new AgentShell(); shell.init(args); shell.start(); @@ -636,4 +650,5 @@ public class AgentShell implements IAgentShell { System.out.println(e.getMessage()); } } + } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcc288c8/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index e8fdb2f..d7e80d6 100644 --- a/pom.xml +++ b/pom.xml @@ -84,6 +84,7 @@ <cs.replace.properties>build/replace.properties</cs.replace.properties> <cs.libvirt-java.version>0.4.9</cs.libvirt-java.version> <cs.target.dir>target</cs.target.dir> + <cs.daemon.version>1.0.10</cs.daemon.version> </properties> <distributionManagement> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcc288c8/usage/pom.xml ---------------------------------------------------------------------- diff --git a/usage/pom.xml b/usage/pom.xml index 0ad59b4..e35d0eb 100644 --- a/usage/pom.xml +++ b/usage/pom.xml @@ -40,7 +40,7 @@ <dependency> <groupId>commons-daemon</groupId> <artifactId>commons-daemon</artifactId> - <version>1.0.10</version> + <version>${cs.daemon.version}</version> </dependency> </dependencies> <build>
