本文整理汇总了Scala中akka.actor.Status.Success类的典型用法代码示例。如果您正苦于以下问题:Scala Success类的具体用法?Scala Success怎么用?Scala Success使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Success类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ExecutionLauncher
//设置package包名称以及导入依赖的类
package net.mikolak.pomisos.process
import akka.actor.{Actor, ActorLogging, Props}
import net.mikolak.pomisos.prefs.Execution
import scala.sys.process._
import language.postfixOps
import akka.actor.Status.Success
class ExecutionLauncher(execution: Execution) extends Actor with ActorLogging with Launcher with CommandExecution {
import ExecutionLauncher._
private val cmd = execution.cmd
private def running_?() = cmd.exists(c => s"pgrep -f $c".!(devnullProcessLogger) == 0)
protected def main: Receive = {
case OnBreak =>
if (!running_?()) {
cmd.foreach(c => {
log.debug(s"Launching command: $c")
context.actorOf(Props[DeferredExecutor]) ! (s"nohup $c", CodesToIgnore)
})
}
case OnPomodoro =>
var killsLeft = KillsToTry
log.debug(s"Attempting to kill process for: $cmd")
while (running_?() && killsLeft > 0) {
cmd.foreach { c =>
execute(s"pkill -f $c")
killsLeft -= 1
}
}
if (running_?() && killsLeft == 0) {
reportError(s"Failed to kill process $cmd after $KillsToTry attempts.")
} else {
log.debug(s"Successfully killed process for: $cmd")
}
}
}
object ExecutionLauncher {
type ErrorInfo = (Int, String)
type CommandStatus = Either[ErrorInfo, Success]
val KillsToTry = 10
private val RootSigReturnCode = 128
private val SigTermCode = RootSigReturnCode + 15
private val KillCode = RootSigReturnCode + 9
val CodesToIgnore = Set(SigTermCode, KillCode)
def devnullProcessLogger = ProcessLogger(_ => (), _ => ())
}