Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit ee26eaa7f8c097cba93619b7979e291818fa4afb 1 parent 4795044
Takeru Ohta authored
2  src/main/scala/daemon/Daemon.scala
View
@@ -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())
}
9 src/main/scala/service/Daemon.scala
View
@@ -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 {
Please sign in to comment.
Something went wrong with that request. Please try again.