Permalink
Browse files

プロセスkill後の自動再起動に対応

  • Loading branch information...
1 parent 4795044 commit ee26eaa7f8c097cba93619b7979e291818fa4afb @sile committed Jun 3, 2012
Showing with 5 additions and 6 deletions.
  1. +1 −1 src/main/scala/daemon/Daemon.scala
  2. +4 −5 src/main/scala/service/Daemon.scala
@@ -8,7 +8,7 @@ class Daemon(executor: (() => Instance)) {
var instance: Option[Instance] = None
def exec() {
- if (instance.isDefined) throw new IllegalStateException()
+ if (isRunning) return;
instance = Some(executor())
}
@@ -6,20 +6,19 @@ import com.twitter.conversions.time._
import com.twitter.finagle.builder.ClientBuilder
import com.twitter.finagle.service.{Backoff,RetryPolicy}
import com.twitter.finagle.http.{Http,Request,Method}
-import com.twitter.util.{Future,Promise}
+import com.twitter.util.{Future,Promise,Time}
import org.jboss.netty.handler.codec.http._
import jp.w3ch.psm.daemon
-
+import jp.w3ch.psm.util.Timer;
class Daemon(command:String, address:InetSocketAddress) extends HttpService {
-
val executor = daemon.Daemon(command)
val port = new Port(address)
- lazy val exec = executor.exec()
+ def exec = executor.exec()
- def this(command:String, address: Int) = this(command, new InetSocketAddress(address))
+ def this(command:String, address: Int) = this(command, new InetSocketAddress("127.0.0.1", address))
override def apply(request:HttpRequest) = {
for {

0 comments on commit ee26eaa

Please sign in to comment.