我最近遇到了一个问题,即使是一个简单的 akka 微内核模型应用程序。它不能在亚马逊 ec2 上熬夜。这是日志
Starting Akka...
Running Akka 2.0.5
Deploying file:/data/akka-scala/akka-2.0.5/deploy/catchif2_2.9.2-0.1-SNAPSHOT.jar
[DEBUG] [03/02/2013 09:35:32.626] [main] [EventStream] StandardOutLogger started
[DEBUG] [03/02/2013 09:35:33.415] [main] [EventStream(akka://hellokernel)] logger log1-Slf4jEventHandler started
[DEBUG] [03/02/2013 09:35:33.416] [main] [EventStream(akka://hellokernel)] Default Loggers started
Starting up com.catchif.HelloKernel
Successfully started Akka
Shutting down Akka...
Shutting down com.catchif.HelloKernel
Received message 'HELLO world!'
Successfully shut down Akka
基本上它会立即自动启动和关闭。
我在我的 Mac 上运行相同的代码。它保持完美。除此以外,日志中没有其他信息:
03/02 09:35:33 INFO [hellokernel-akka.actor.default-dispatcher-4] a.e.s.Slf4jEventHandler - Slf4jEventHandler started
03/02 09:35:33 DEBUG[hellokernel-akka.actor.default-dispatcher-3] a.e.EventStream - logger log1-Slf4jEventHandler started
03/02 09:35:33 DEBUG[hellokernel-akka.actor.default-dispatcher-3] a.e.EventStream - Default Loggers started
代码也很简单。
import akka.actor.{ Actor, ActorSystem, Props }
import akka.kernel.Bootable
case object Start
class HelloActor extends Actor {
val worldActor = context.actorOf(Props[WorldActor])
def receive = {
case Start ⇒ worldActor ! "Hello"
case message: String ⇒
println("Received message '%s'" format message)
}
}
class WorldActor extends Actor {
def receive = {
case message: String ⇒ sender ! (message.toUpperCase + " world!")
}
}
class HelloKernel extends Bootable {
val system = ActorSystem("hellokernel")
def startup = {
system.actorOf(Props[HelloActor]) ! Start
}
def shutdown = {
system.shutdown()
}
}
不知道为什么会这样。我确实看到它在亚马逊上停留了一次,但后来一直失败。
在此先感谢,最好的,詹姆斯