in uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/container/deployer/vinci/VinciCasProcessorDeployer.java [487:608]
private void launchLocalService(ProcessingContainer aProcessingContainer,
CasProcessorConfiguration casProcessorConfig, boolean redeploy, int howMany)
throws CasProcessorDeploymentException {
try {
Execute exec = casProcessorConfig.getExecSpec();
String cmd[] = exec.getCmdLine();
String[] execCommand = new String[3];
if (System.getProperty("os.name").equalsIgnoreCase("linux")) {
execCommand[0] = "/bin/sh";
execCommand[1] = "-c";
}
StringBuffer sb = new StringBuffer();
// The command line has been established, now make sure that we tell the Cas Processor about
// the
// VNS port in use. In this logic the VNS is querried for its port number and this will the
// port
// provided to the Cas Processor. The Cas Processor must read this argument during its start
// up
// to ensure connection to the correct VNS.
for (int i = 0; i < cmd.length; i++) {
if (cmd[i] != null && cmd[i].indexOf("-DVNS_PORT") > -1) {
int vnsPort = vns.getVNSPort();
cmd[i] = "-DVNS_PORT=" + vnsPort;
}
sb.append(" " + cmd[i]);
}
String logDir = "";
if (System.getProperty("LOG_DIR") != null) {
logDir = System.getProperty("LOG_DIR");
if (!logDir.endsWith("/") && !logDir.endsWith("\\")) {
// Append OS specific seperator
logDir += System.getProperty("file.separator");
}
}
sb.append(" >> " + logDir + "\"" + casProcessorConfig.getName() + System.currentTimeMillis()
+ ".log\"" + " 2>&1");
execCommand[2] = sb.toString();
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_vns_started__FINEST",
new Object[] { Thread.currentThread().getName(), casProcessorConfig.getName() });
}
int serviceCount = howMany;
// Spawn off as many processes as defined in CPE descriptor. The exact number of instances is
// equal to
// procesingUnitThreadCount attribute.
while (serviceCount-- > 0) {
for (int i = 0; cmd != null && i < cmd.length; i++) {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_launching_with_service_cmd__FINEST",
new Object[] { Thread.currentThread().getName(), casProcessorConfig.getName(),
String.valueOf(i), cmd[i] });
}
}
String[] env;
if ((env = exec.getEnvironment()) != null && env.length > 0) {
for (int i = 0; i < env.length; i++) {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_launching_with_service_env__FINEST",
new Object[] { Thread.currentThread().getName(), casProcessorConfig.getName(),
String.valueOf(i), env[i] });
}
}
if (System.getProperty("os.name").equalsIgnoreCase("linux")) {
for (int i = 0; execCommand != null && i < execCommand.length; i++) {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_launching_with_service_exec__FINEST",
new Object[] { Thread.currentThread().getName(),
casProcessorConfig.getName(), String.valueOf(i), execCommand[i] });
}
}
Runtime.getRuntime().exec(execCommand, env);
} else {
Runtime.getRuntime().exec(cmd, env);
}
} else {
if (System.getProperty("os.name").equalsIgnoreCase("linux")) {
for (int i = 0; execCommand != null && i < execCommand.length; i++) {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_launching_with_service_exec__FINEST",
new Object[] { Thread.currentThread().getName(),
casProcessorConfig.getName(), String.valueOf(i), execCommand[i] });
}
}
Runtime.getRuntime().exec(execCommand);
} else {
Runtime.getRuntime().exec(cmd);
}
}
}
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_connecting_to_services__FINEST",
new Object[] { Thread.currentThread().getName(), casProcessorConfig.getName() });
}
// Services has been started so now connect proxies to them.
connectToServices(aProcessingContainer, casProcessorConfig, redeploy, howMany);
} catch (ConnectException e) {
e.printStackTrace();
throw new CasProcessorDeploymentException(e);
} catch (Exception e) {
e.printStackTrace();
throw new CasProcessorDeploymentException(e);
}
}