=doc Describe how to use microKernel with sbt-native-packager

(cherry picked from commit 6a79ad1287fb776eac1cac07a8a45dc0b597cede)

Conflicts:
	project/plugins.sbt
This commit is contained in:
Max Cai 2014-10-01 10:08:26 -04:00 committed by Patrik Nordwall
parent 51d415d4e8
commit 3ecdf40806
4 changed files with 44 additions and 22 deletions

View file

@ -13,30 +13,35 @@ The Akka Microkernel is included in the Akka download found at `downloads`_.
.. _downloads: http://akka.io/downloads .. _downloads: http://akka.io/downloads
To run an application with the microkernel you need to create a Bootable class To run an application with the microkernel you need to create a Bootable class
that handles the startup and shutdown the application. An example is included below. that handles the startup and shutdown the application.
Put your application jar in the ``deploy`` directory and additional dependencies in the ``lib`` directory
to have them automatically loaded and placed on the classpath.
To start the kernel use the scripts in the ``bin`` directory, passing the boot
classes for your application.
The start script adds ``config`` directory first in the classpath, followed by ``lib/*``.
It runs java with main class ``akka.kernel.Main`` and the supplied Bootable class as
argument.
Example command (on a unix-based system):
.. code-block:: none
bin/akka sample.kernel.hello.HelloKernel
Use ``Ctrl-C`` to interrupt and exit the microkernel.
On a Windows machine you can also use the bin/akka.bat script.
The code for the Hello Kernel example (see the ``HelloKernel`` class for an example The code for the Hello Kernel example (see the ``HelloKernel`` class for an example
of creating a Bootable): of creating a Bootable):
.. includecode:: ../../../akka-samples/akka-sample-hello-kernel/src/main/scala/sample/kernel/hello/HelloKernel.scala .. includecode:: ../../../akka-samples/akka-sample-hello-kernel/src/main/scala/sample/kernel/hello/HelloKernel.scala
Add `sbt-native-packager <https://github.com/sbt/sbt-native-packager>`_ to the plugins.sbt
.. code-block:: none
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0-M2")
Use the package settings for ``akka_application``, and specify the mainClass in build.sbt
.. includecode:: ../../../akka-samples/akka-sample-hello-kernel/build.sbt
Use sbt task ``stage`` to generate the start script. Also you can use task ``universal:packageZipTarball`` to package the application.
To start the application (on a unix-based system):
.. code-block:: none
./target/universal/stage/bin/hello-kernel
Use ``Ctrl-C`` to interrupt and exit the microkernel.
On a Windows machine you can also use the ``target\universal\stage\bin\hello-kernel.bat`` script.

View file

@ -0,0 +1,12 @@
import NativePackagerKeys._
packageArchetype.akka_application
name := """hello-kernel"""
mainClass in Compile := Some("sample.kernel.hello.HelloKernel")
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-kernel" % "2.4-SNAPSHOT",
"com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT"
)

View file

@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0-M2")

View file

@ -23,5 +23,9 @@ addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.3.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2")
// needed for the akka-sample-hello-kernel
// it is also defined in akka-samples/akka-sample-hello-kernel/project/plugins.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0-M2")
// stats reporting // stats reporting
libraryDependencies += "com.timgroup" % "java-statsd-client" % "2.0.0" libraryDependencies += "com.timgroup" % "java-statsd-client" % "2.0.0"