Skip to content

Commit

Permalink
test #974: improve printouts when backend dies
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdu committed Dec 14, 2011
2 parents 71e3cb1 + 7957c4c commit 326bb0e
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,21 @@ private Process startRuntimeProcess(final BackendData data) {
final ProcessBuilder builder = new ProcessBuilder(cmds);
builder.directory(workingDirectory);
setEnvironment(data, builder);
int code = 0;
try {
Process process = builder.start();
try {
code = process.exitValue();
final int code = process.exitValue();
ErlLogger.error(
"Could not create runtime (exit code = %d): %s", code,
Arrays.toString(cmds));
process = null;
} catch (final IllegalThreadStateException e) {
ErlLogger.debug("process is running");
}
return process;
} catch (final IOException e) {
ErlLogger.error("Could not create runtime (exit code = %d): %s",
code, Arrays.toString(cmds));
ErlLogger.error("Could not create runtime: %s",
Arrays.toString(cmds));
ErlLogger.error(e);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private String getErlangTopic() {
public void register() {
final String fullTopic = ErlangEventPublisher.getFullTopic(topic,
backend);
ErlLogger.info("Register event handler for " + topic + ": " + this);
// ErlLogger.info("Register event handler for " + topic + ": " + this);
final BundleContext context = ErlangPlugin.getDefault().getBundle()
.getBundleContext();
try {
Expand Down
12 changes: 5 additions & 7 deletions org.erlide.core/src/org/erlide/core/debug/ErtsProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.debug.core.model.RuntimeProcess;
import org.erlide.core.backend.BackendData;
import org.erlide.core.backend.ErtsWatcherRunnable;
import org.erlide.core.backend.runtimeinfo.RuntimeInfo;
import org.erlide.core.internal.backend.ErtsWatcherRunnable;
import org.erlide.jinterface.ErlLogger;

public class ErtsProcess extends RuntimeProcess {
Expand All @@ -26,8 +25,7 @@ public ErtsProcess(final Process process, final BackendData data) {
super(data.getLaunch(), process, data.getNodeName(), null);
ErlLogger.debug("# create ErtsProcess: " + data.getNodeName());

final RuntimeInfo info = data.getRuntimeInfo();
startWatcher(info, process);
startWatcher(data, process);
}

/**
Expand Down Expand Up @@ -97,9 +95,9 @@ public void terminate() throws DebugException {
super.terminate();
}

private void startWatcher(final RuntimeInfo info, final Process process) {
final Runnable watcher = new ErtsWatcherRunnable(info.getNodeName(),
info.getWorkingDir(), process);
private void startWatcher(final BackendData data, final Process process) {
final Runnable watcher = new ErtsWatcherRunnable(data.getNodeName(),
data.getWorkingDir(), process);
final Thread thread = new Thread(null, watcher, "ErtsProcess watcher");
thread.setDaemon(true);
thread.setPriority(Thread.MIN_PRIORITY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,16 @@ private RuntimeInfo getIdeRuntimeInfo() {
final RuntimeInfo info = RuntimeInfo.copy(
runtimeInfoManager.getErlideRuntime(), false);
if (info != null) {
final String defLabel = BackendFactory.getLabelProperty();
if (defLabel != null) {
info.setNodeName(defLabel);
} else {
final String nodeName = BackendUtils.getErlideNodeNameTag()
+ "_erlide";
info.setNodeName(nodeName);
}
final String dflt = BackendUtils.getErlideNodeNameTag() + "_erlide";
final String defLabel = getLabelProperty(dflt);
info.setNodeName(defLabel);
info.setCookie("erlide");
}
return info;
}

public static String getLabelProperty() {
return System.getProperty("erlide.label", null);
private static String getLabelProperty(final String dflt) {
return System.getProperty("erlide.label", dflt);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ private void tryConnect() throws RpcException {
case CONNECTED:
break;
case DOWN:
final String msg = "BackendImpl %s is down";
final String msg = "Backend '%s' is down";
// XXX restart it??
throw new RpcException(String.format(msg, peerName));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Contributors:
* Vlad Dumitrescu
*******************************************************************************/
package org.erlide.core.backend;
package org.erlide.core.internal.backend;

import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -43,22 +43,24 @@ public ErtsWatcherRunnable(final String nodeName, final String workingDir,
@Override
@SuppressWarnings("boxing")
public void run() {
try {
final int v = process.waitFor();
final String msg = "Backend '%s' terminated with exit code %d.";
ErlLogger.error(msg, nodeName, v);
do {
try {
final int v = process.waitFor();
final String msg = "Backend '%s' terminated with exit code %d.";
ErlLogger.error(msg, nodeName, v);

// 129 = SIGHUP (probably logout, ignore)
// 143 = SIGTERM (probably logout, ignore)
// 137 = SIGKILL (probably killed by user)
if (v > 1 && v != 143 && v != 129 && v != 137
&& CommonUtils.isEricssonUser()) {
createReport(v, msg);
// 129 = SIGHUP (probably logout, ignore)
// 143 = SIGTERM (probably logout, ignore)
// 137 = SIGKILL (probably killed by user)
if (v > 1 && v != 143 && v != 129 && v != 137
&& CommonUtils.isEricssonUser()) {
createReport(v, msg);
}
// FIXME backend.setExitStatus(v);
return;
} catch (final InterruptedException e) {
}
// FIXME backend.setExitStatus(v);
} catch (final InterruptedException e) {
ErlLogger.warn("BackendImpl watcher was interrupted");
}
} while (true);
}

private void createReport(final int v, final String msg) {
Expand Down
2 changes: 1 addition & 1 deletion org.erlide.ui.tests/projects/Erlide_tests.launch
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}&#13;&#10;-consoleLog -verbose -debug"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Derlide.clearCacheAvailable=true &#13;&#10;-Xms96m &#13;&#10;-Xmx384m&#13;&#13;&#10;-Derlide.console.stdout=false&#13;&#13;&#10;-D__eclipse.p2.data.area=c:/apps/eclipse352_ref/eclipse/p2/&#13;&#13;&#10;-Declipse.p2.profile=SDKProfile&#13;&#13;&#10;-Derlide.devel=true&#13;&#10;-Derlide.rpcmonitor&#13;&#10;-Derlide.rpcmonitor.full"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Derlide.clearCacheAvailable=true &#13;&#10;-Xms96m &#13;&#10;-Xmx384m&#13;&#13;&#10;-Derlide.console.stdout=false&#13;-D__eclipse.p2.data.area=c:/apps/eclipse352_ref/eclipse/p2/&#13;-Declipse.p2.profile=SDKProfile&#13;-Derlide.devel=true&#13;&#10;-Derlide.rpcmonitor&#13;&#10;-Derlide.rpcmonitor.full&#10;-Derlide.monitor.ide=true"/>
<booleanAttribute key="org.eclipse.tptp.platform.jvmti.client.ATTR_EXEC_AUTO_POLLING" value="true"/>
<booleanAttribute key="org.eclipse.tptp.platform.jvmti.client.ATTR_EXEC_CPU_TIME" value="true"/>
<booleanAttribute key="org.eclipse.tptp.platform.jvmti.client.ATTR_EXEC_FLOW" value="true"/>
Expand Down

0 comments on commit 326bb0e

Please sign in to comment.