Skip to content

Commit

Permalink
Add WorkerUncaughtExceptionHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyuhong committed May 16, 2019
1 parent 1490a98 commit 66b6561
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.ray.api.Ray;
import org.ray.runtime.AbstractRayRuntime;
import org.ray.runtime.util.WorkerUncaughtExceptionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -15,6 +16,7 @@ public class DefaultWorker {
public static void main(String[] args) {
try {
System.setProperty("ray.worker.mode", "WORKER");
Thread.setDefaultUncaughtExceptionHandler(new WorkerUncaughtExceptionHandler());
Ray.init();
LOGGER.info("Worker started.");
((AbstractRayRuntime)Ray.internal()).loop();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.ray.runtime.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WorkerUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {

private static final Logger LOGGER =
LoggerFactory.getLogger(WorkerUncaughtExceptionHandler.class);

@Override
public void uncaughtException(Thread thread, Throwable ex) {
LOGGER.error("Uncaught exception in thread {}: {}", thread, ex);
}
}

0 comments on commit 66b6561

Please sign in to comment.