Get command line arguments when working with Akka microkernel?

I have an Akka microkernel below:

class ServiceKernel extends Bootable {

  val system = ActorSystem("service-kernel")

  def startup = {
    system.actorOf(Props(new Boot(false))) ! Start
  }

  def shutdown = {
    system.shutdown()
  }
}

Since the kernel extends Bootable, not Apphow can I access the command line arguments used when starting the kernel? For example, if I start the kernel using start namespace.ServiceKernel -d rundevmodeor similar. Thank!

Additional Information

I thought it was worth adding this information about running the script into the microkernel. As /bin/startyou will notice the following:

#!/bin/sh

AKKA_HOME="$(cd "$(cd "$(dirname "$0")"; pwd -P)"/..; pwd)"
AKKA_CLASSPATH="$AKKA_HOME/config:$AKKA_HOME/lib/*"
JAVA_OPTS="-Xms256M -Xmx512M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2"

java $JAVA_OPTS -cp "$AKKA_CLASSPATH" -Dakka.home="$AKKA_HOME" akka.kernel.Main "$@"

Although om-nom-nom originally proposed options -D, it looks the way it is used, and the main start parameter is passed to the class akka.kernel.Main(which in this case will be the class ServiceKernelabove).

+5
source
2

:

object Foo extends App {
    val debugModeOn = System.getProperty("debugmode") != null
    val msg = if (debugModeOn) "in debug mode" else "not in debug mode"
    println(msg)
}

ยป scala Foo -Ddebugmode
in debug mode
ยป scala Foo            
not in debug mode

, :

ยป scala Foo -Ddebugmode=false
in debug mode

P.S. , , propOrNone, propOrElse ..

+3

, sh script JAVA_OPTS, , , . , JAVA_OPTS script, , -D JAVA_OPTS. , , -D. Hackish, , . -D , , , , , .

0

All Articles