Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 738826] Start/Stop/Restart operation should support RPM System V …
Browse files Browse the repository at this point in the history
…init script with different service names.
  • Loading branch information
Jean-Frederic Clere authored and jfclere committed Jun 19, 2014
1 parent 7c80101 commit e1ebf1f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public enum ControlMethod {
public static final String PLUGIN_CONFIG_START_SCRIPT = "startScript";
public static final String START_WAIT_MAX_PROP = "startWaitMax";
public static final String STOP_WAIT_MAX_PROP = "stopWaitMax";
public static final String PLUGIN_CONFIG_SERVICE_NAME="serviceName";

private Log log = LogFactory.getLog(this.getClass());

Expand Down Expand Up @@ -419,6 +420,12 @@ private File resolvePathRelativeToHomeDir(@NotNull String path) {
return resolvePathRelativeToHomeDir(this.resourceContext.getPluginConfiguration(), path);
}

public String getServiceName() {
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
String servicename = pluginConfig.getSimpleValue(TomcatServerComponent.PLUGIN_CONFIG_SERVICE_NAME, null);
return servicename;
}

static File resolvePathRelativeToHomeDir(Configuration pluginConfig, String path) {
File configDir = new File(path);
if (!FileUtil.isAbsolutePath(path)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,7 @@ private ProcessExecution getScriptStart(Configuration pluginConfiguration) {

private ProcessExecution getRpmStart(Configuration pluginConfiguration) {
ProcessExecution processExecution;
String catalinaHome = this.serverComponent.getCatalinaHome().getPath();
String rpm = getTomcatServiceNum(catalinaHome);
String rpm = getTomcatServiceNum();

if (isWindows()) {
processExecution = new ProcessExecution("net");
Expand Down Expand Up @@ -342,7 +341,11 @@ private ProcessExecution getScriptShutdown(Configuration pluginConfiguration) {
return processExecution;
}

private static String getTomcatServiceNum(String catalinaHome) {
private String getTomcatServiceNum() {
String catalinaHome = this.serverComponent.getCatalinaHome().getPath();
String serviceName = this.serverComponent.getServiceName();
if (serviceName != null)
return serviceName;
String rpm = TomcatDiscoveryComponent.EWS_TOMCAT_8;
if (TomcatDiscoveryComponent.isTomcat7(catalinaHome))
rpm = TomcatDiscoveryComponent.EWS_TOMCAT_7;
Expand All @@ -355,8 +358,7 @@ private static String getTomcatServiceNum(String catalinaHome) {

private ProcessExecution getRpmShutdown() {
ProcessExecution processExecution;
String catalinaHome = this.serverComponent.getCatalinaHome().getPath();
String rpm = getTomcatServiceNum(catalinaHome);
String rpm = getTomcatServiceNum();

if (isWindows()) {
processExecution = new ProcessExecution("net");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@
<c:simple-property name="value" />
</c:map-property>
</c:list-property>

<c:simple-property
name="serviceName"
displayName="Service name"
type="string"
required="false"
description="In case of multiple tomcat installations in the same box it is possible
to do have several service files like tomcat1, tomcat2 etc.
Put here the name you are using."/>
</c:group>

<c:group
Expand Down Expand Up @@ -1260,4 +1269,4 @@

</server>

</plugin>
</plugin>

0 comments on commit e1ebf1f

Please sign in to comment.