modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
| 32 ++++++++--
1 file changed, 28 insertions(+), 4 deletions(-)
New commits:
commit 8dd9aaa949c105114236d66c103e39d394188b22
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Apr 29 12:08:00 2013 -0400
Get Agent to install and start as windows service via 'rhqctl install'
diff --git
a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
index 4970a2a..596de48 100644
---
a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
+++
b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
@@ -473,13 +473,37 @@ public class Install extends ControlCommand {
}
private void startAgent(File agentBasedir) throws Exception {
- File agentBinDir = new File(agentBasedir, "bin");
-
- org.apache.commons.exec.CommandLine commandLine =
getCommandLine("rhq-agent-wrapper", "start");
-
Executor executor = new DefaultExecutor();
+ File agentBinDir = new File(agentBasedir, "bin");
executor.setWorkingDirectory(agentBinDir);
executor.setStreamHandler(new PumpStreamHandler());
+ org.apache.commons.exec.CommandLine commandLine;
+
+ if (isWindows()) {
+ // For windows we will [re-]install the server as a windows service, then
start the service.
+
+ commandLine = getCommandLine("rhq-agent-wrapper",
"stop");
+ try {
+ executor.execute(commandLine);
+ } catch (Exception e) {
+ // Ignore, service may not exist or be running, , script returns 1
+ log.debug("Failed to stop agent service", e);
+ }
+
+ commandLine = getCommandLine("rhq-agent-wrapper",
"remove");
+ try {
+ executor.execute(commandLine);
+ } catch (Exception e) {
+ // Ignore, service may not exist, script returns 1
+ log.debug("Failed to uninstall agent service", e);
+ }
+
+ commandLine = getCommandLine("rhq-agent-wrapper",
"install");
+ executor.execute(commandLine);
+ }
+
+ // For *nix, just start the server in the background, for Win, now that the
service is installed, start it
+ commandLine = getCommandLine("rhq-agent-wrapper", "start");
executor.execute(commandLine);
}
Show replies by date