Skip to content

Commit 451f361

Browse files
marcoboivelvia
authored andcommitted
fix(job-server): fix for 916,917: logging for manager_start.sh (spark-jobserver#918)
fix for 916,917: logging for manager_start.sh * Add logging when starting context through manager_start.sh * manager_start.sh process is now fully asynchronous * spark-submit logs routed to main application logs * removed wait-for-manager-start
1 parent 7b93963 commit 451f361

File tree

4 files changed

+7
-30
lines changed

4 files changed

+7
-30
lines changed

bin/manager_start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ else
4848
$appdir/spark-job-server.jar $2 $3 $4 $conffile'
4949
fi
5050

51-
eval $cmd > /dev/null 2>&1 &
52-
# exec java -cp $CLASSPATH $GC_OPTS $JAVA_OPTS $LOGGING_OPTS $CONFIG_OVERRIDES $MAIN $1 $2 $conffile 2>&1 &
51+
eval $cmd
52+

job-server/config/docker.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ spark {
6565

6666
deploy {
6767
manager-start-cmd = "app/manager_start.sh"
68-
wait-for-manager-start = false
6968
}
7069

7170
# Note that you can use this file to define settings not only for job server,

job-server/src/main/resources/application.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,4 @@ shiro {
243243

244244
deploy {
245245
manager-start-cmd = "./manager_start.sh"
246-
# If true, wait for the process which starts contexts in a forked JVM to exit. Set to false
247-
# if this process needs to remain in the foreground, e.g. when running in Docker.
248-
wait-for-manager-start = true
249246
}

job-server/src/main/scala/spark/jobserver/AkkaClusterSupervisorActor.scala

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package spark.jobserver
22

3-
import java.io.IOException
43
import java.nio.file.{Files, Paths}
54
import java.nio.charset.Charset
65
import java.util.concurrent.TimeUnit
@@ -20,6 +19,7 @@ import spark.jobserver.common.akka.InstrumentedActor
2019
import scala.concurrent.Await
2120
import akka.pattern.gracefulStop
2221
import org.joda.time.DateTime
22+
import org.slf4j.LoggerFactory
2323
import spark.jobserver.io.JobDAOActor.CleanContextJobInfos
2424

2525
/**
@@ -37,7 +37,6 @@ import spark.jobserver.io.JobDAOActor.CleanContextJobInfos
3737
* {{{
3838
* deploy {
3939
* manager-start-cmd = "./manager_start.sh"
40-
* wait-for-manager-start = true
4140
* }
4241
* }}}
4342
*/
@@ -54,7 +53,6 @@ class AkkaClusterSupervisorActor(daoActor: ActorRef, dataManagerActor: ActorRef)
5453
TimeUnit.SECONDS)
5554
val contextDeletionTimeout = SparkJobUtils.getContextDeletionTimeout(config)
5655
val managerStartCommand = config.getString("deploy.manager-start-cmd")
57-
val waitForManagerStart = config.getBoolean("deploy.wait-for-manager-start")
5856
import context.dispatcher
5957

6058
//actor name -> (context isadhoc, success callback, failure callback)
@@ -238,28 +236,11 @@ class AkkaClusterSupervisorActor(daoActor: ActorRef, dataManagerActor: ActorRef)
238236
cmdString = cmdString + s" ${contextConfig.getString(SparkJobUtils.SPARK_PROXY_USER_PARAM)}"
239237
}
240238

241-
val pb = Process(cmdString)
242-
val pio = new ProcessIO(_ => (),
243-
stdout => scala.io.Source.fromInputStream(stdout)
244-
.getLines.foreach(println),
245-
stderr => scala.io.Source.fromInputStream(stderr).getLines().foreach(println))
246-
logger.info("Starting to execute sub process {}", pb)
247-
val processStart = Try {
248-
val process = pb.run(pio)
249-
if (waitForManagerStart) {
250-
val exitVal = process.exitValue()
251-
if (exitVal != 0) {
252-
throw new IOException("Failed to launch context process, got exit code " + exitVal)
253-
}
254-
}
255-
}
256-
257-
if (processStart.isSuccess) {
258-
contextInitInfos(contextActorName) = (isAdHoc, successFunc, failureFunc)
259-
} else {
260-
failureFunc(processStart.failed.get)
261-
}
239+
val contextLogger = LoggerFactory.getLogger("manager_start")
240+
val process = Process(cmdString.split(" "))
241+
process.run(ProcessLogger(out => contextLogger.info(out), err => contextLogger.warn(err)))
262242

243+
contextInitInfos(contextActorName) = (isAdHoc, successFunc, failureFunc)
263244
}
264245

265246
private def createContextDir(name: String,

0 commit comments

Comments
 (0)