Skip to content

Commit

Permalink
0002040: Can't set windows service dependencies in sym_service.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Nov 4, 2014
1 parent d423d0b commit 6160084
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 7 additions & 0 deletions symmetric-server/src/main/deploy/conf/sym_service.conf
Expand Up @@ -76,3 +76,10 @@ wrapper.description=Database Synchronization

# Mode in which the service is installed. Either auto or manual.
wrapper.starttype=auto

#********************************************************************
# Wrapper Windows NT/2000/XP Service Properties
#********************************************************************

# Service dependencies. Use + prefix for groups.
wrapper.ntservice.dependency.1=
Expand Up @@ -262,11 +262,20 @@ public void install() {
throw new WrapperException(Constants.RC_ALREADY_INSTALLED, 0, "Service " + config.getName() + " is already installed");
} else {
System.out.println("Installing " + config.getName() + " ...");


String dependencies = null;
if (config.getDependencies() != null && config.getDependencies().size() > 0) {
StringBuffer sb = new StringBuffer();
for (String dependency : config.getDependencies()) {
sb.append(dependency).append("\0");
}
dependencies = sb.append("\0").toString();
}

service = advapi.CreateService(manager, config.getName(), config.getDisplayName(), Winsvc.SERVICE_ALL_ACCESS,
WinsvcEx.SERVICE_WIN32_OWN_PROCESS, config.isAutoStart() ? WinsvcEx.SERVICE_AUTO_START
: WinsvcEx.SERVICE_DEMAND_START, WinsvcEx.SERVICE_ERROR_NORMAL,
commandToString(getWrapperCommand("init")), null, null, null, null, null);
commandToString(getWrapperCommand("init")), null, null, dependencies, null, null);

if (service != null) {
Advapi32Ex.SERVICE_DESCRIPTION desc = new Advapi32Ex.SERVICE_DESCRIPTION(config.getDescription());
Expand Down
Expand Up @@ -28,6 +28,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

Expand Down Expand Up @@ -143,6 +144,10 @@ public boolean isAutoStart() {
return getProperty(prop, "wrapper.starttype", "auto").equalsIgnoreCase("auto");
}

public List<String> getDependencies() {
return prop.get("wrapper.ntservice.dependency");
}

public String getJavaCommand() {
return getProperty(prop, "wrapper.java.command", "java");
}
Expand Down

0 comments on commit 6160084

Please sign in to comment.