-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
package jp.w3ch.psm.config | ||
|
||
import jp.w3ch.psm.service | ||
import jp.w3ch.psm.daemon.Daemon | ||
|
||
|
||
trait ConfigurationUtil { | ||
|
||
def addDaemon(d:Daemon):Unit | ||
|
||
val port = new service.Port(_:Int) | ||
val daemon = new service.Daemon(_:String, _:Int) | ||
val textResponse = new service.TextResponse(_) | ||
|
||
def daemon(command:String, port:Int) = { | ||
val d = Daemon(command) | ||
addDaemon(d) | ||
|
||
new service.Daemon(d, port) | ||
} | ||
} | ||
|
||
// vim: set shiftwidth=2 expandtab : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package jp.w3ch.psm.daemon | ||
|
||
|
||
/** | ||
* 各種プロセスを管理します。 | ||
*/ | ||
class Pool(daemons: Seq[Daemon]) { | ||
|
||
def stop() { | ||
daemons.foreach { _.stop() } | ||
} | ||
|
||
} | ||
|
||
// vim: set shiftwidth=2 expandtab: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package jp.w3ch.psm.daemon | ||
|
||
import org.jboss.netty.handler.codec.http._ | ||
import com.twitter.finagle.Service | ||
import org.specs2.mutable._ | ||
import org.specs2.mock._ | ||
|
||
import jp.w3ch.psm.DispatchingServer | ||
import jp.w3ch.psm.service.HttpService | ||
|
||
|
||
class PoolSpec extends Specification with Mockito { | ||
|
||
"stops all daemons" >> { | ||
|
||
"when single daemon is running" in { | ||
val daemon = mock[Daemon] | ||
|
||
val subject = new Pool(Seq(daemon)) | ||
|
||
subject.stop() | ||
|
||
there was one(daemon).stop() | ||
} | ||
|
||
"when multiple daemons are running" in { | ||
val daemons = Seq(mock[Daemon], mock[Daemon]) | ||
|
||
val subject = new Pool(daemons) | ||
|
||
subject.stop() | ||
|
||
there was one(daemons(0)).stop() | ||
there was one(daemons(1)).stop() | ||
} | ||
} | ||
|
||
} | ||
|
||
// vim: set ts=2 sw=2 et: |