Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.apache.spark.SecurityManager
import org.apache.spark.deploy.Command
import org.apache.spark.internal.Logging
import org.apache.spark.launcher.WorkerCommandBuilder
import org.apache.spark.util.Utils
import org.apache.spark.util.{ShutdownHookManager, Utils}

/**
* Utilities for running commands with the spark classpath.
Expand Down Expand Up @@ -102,10 +102,14 @@ object CommandUtils extends Logging {
}

/** Spawn a thread that will redirect a given stream to a file */
private var shutdownHook: AnyRef = null
def redirectStream(in: InputStream, file: File) {
val out = new FileOutputStream(file, true)
// TODO: It would be nice to add a shutdown hook here that explains why the output is
// terminating. Otherwise if the worker dies the executor logs will silently stop.

shutdownHook = ShutdownHookManager.addShutdownHook { () =>
logInfo("Worker shutting down,executor logs silently stop.")
}

new Thread("redirect output to " + file) {
override def run() {
try {
Expand Down