2011-05-25 14:52:27 -07:00
|
|
|
|
2012-05-15 16:01:32 +02:00
|
|
|
.. _microkernel-scala:
|
2011-05-25 14:52:27 -07:00
|
|
|
|
2013-04-19 13:21:15 +02:00
|
|
|
Microkernel
|
2012-05-11 10:36:43 +02:00
|
|
|
===================
|
2011-05-25 14:52:27 -07:00
|
|
|
|
2012-05-20 16:00:24 +02:00
|
|
|
The purpose of the Akka Microkernel is to offer a bundling mechanism so that you can distribute
|
|
|
|
|
an Akka application as a single payload, without the need to run in a Java Application Server or manually
|
|
|
|
|
having to create a launcher script.
|
|
|
|
|
|
2011-12-15 11:42:06 +13:00
|
|
|
The Akka Microkernel is included in the Akka download found at `downloads`_.
|
|
|
|
|
|
2014-03-13 08:54:41 +01:00
|
|
|
.. _downloads: http://akka.io/downloads
|
2011-12-15 11:42:06 +13:00
|
|
|
|
2014-10-01 10:08:26 -04:00
|
|
|
To run an application with the microkernel you need to create a Bootable class
|
|
|
|
|
that handles the startup and shutdown the application.
|
2011-12-15 11:42:06 +13:00
|
|
|
|
2014-10-01 10:08:26 -04:00
|
|
|
The code for the Hello Kernel example (see the ``HelloKernel`` class for an example
|
|
|
|
|
of creating a Bootable):
|
2011-12-15 11:42:06 +13:00
|
|
|
|
2014-10-01 10:08:26 -04:00
|
|
|
.. includecode:: ../../../akka-samples/akka-sample-hello-kernel/src/main/scala/sample/kernel/hello/HelloKernel.scala
|
2014-01-17 11:07:10 +01:00
|
|
|
|
|
|
|
|
|
2014-10-01 10:08:26 -04:00
|
|
|
Add `sbt-native-packager <https://github.com/sbt/sbt-native-packager>`_ to the plugins.sbt
|
2011-12-15 11:42:06 +13:00
|
|
|
|
|
|
|
|
.. code-block:: none
|
|
|
|
|
|
2014-10-01 10:08:26 -04:00
|
|
|
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0-M2")
|
2011-12-15 11:42:06 +13:00
|
|
|
|
2014-10-01 10:08:26 -04:00
|
|
|
Use the package settings for ``akka_application``, and specify the mainClass in build.sbt
|
2011-12-15 11:42:06 +13:00
|
|
|
|
2014-10-01 10:08:26 -04:00
|
|
|
.. includecode:: ../../../akka-samples/akka-sample-hello-kernel/build.sbt
|
2011-12-15 11:42:06 +13:00
|
|
|
|
|
|
|
|
|
2014-10-01 10:08:26 -04:00
|
|
|
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.
|
|
|
|
|
|
2012-01-30 11:14:55 +01:00
|
|
|
|