Skip to content

Commit

Permalink
Deleting unused deps.
Browse files Browse the repository at this point in the history
Adding linter to the project.
Adding logging to a file instead of stdin/stderr.
  • Loading branch information
fcofdez committed Apr 23, 2015
1 parent 0c886dc commit 2820353
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
13 changes: 9 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@ version := "0.1"

scalaVersion := "2.11.6"

resolvers += "Linter Repository" at "https://hairyfotr.github.io/linteRepo/releases"

addCompilerPlugin("com.foursquare.lint" %% "linter" % "0.1.9")

scalacOptions += "-deprecation"

scalacOptions += "-feature"

libraryDependencies ++= {
val akkaStreamV = "1.0-M3"
val sprayV = "1.3.3"
Seq(
"org.fusesource" % "sigar" % "1.6.4",
"io.spray" %% "spray-can" % sprayV,
"io.spray" %% "spray-client" % sprayV,
"io.spray" %% "spray-routing" % sprayV,
"com.github.nscala-time" %% "nscala-time" % "1.8.0",
"com.typesafe.akka" %% "akka-contrib" % "2.3.9",
"com.typesafe.akka" %% "akka-testkit" % "2.3.9",
"com.typesafe.akka" %% "akka-stream-experimental" % akkaStreamV,
"com.typesafe.akka" %% "akka-http-core-experimental" % akkaStreamV,
"com.typesafe.akka" %% "akka-http-experimental" % akkaStreamV,
"com.typesafe.akka" %% "akka-http-spray-json-experimental" % akkaStreamV,
"com.typesafe.akka" %% "akka-http-testkit-experimental" % akkaStreamV,
"com.github.seratch" %% "awscala" % "0.5.+",
"org.scalatest" %% "scalatest" % "2.2.1" % "test",
"commons-io" % "commons-io" % "2.4" % "test"
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ akka {

log-dead-letters = 1
log-dead-letters-during-shutdown = on
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "DEBUG"

cluster {
seed-nodes = [
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>log/app.log</file>
<append>true</append>
<encoder>
<pattern>%date{yyyy-MM-dd} %X{akkaTimestamp} %-5level[%thread] %logger{1} - %msg%n</pattern>
</encoder>
</appender>

<root level="DEBUG">
<appender-ref ref="FILE"/>
</root>
</configuration>
6 changes: 2 additions & 4 deletions src/main/scala/worker/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ trait MyService extends HttpService with Protocols {

trait Backend {

def startWorker(port: Int): Unit = {
// load worker.conf
def startWorker(): Unit = {
val conf = ConfigFactory.load("worker")
val system = ActorSystem("WorkerSystem", conf)
val initialContacts = immutableSeq(conf.getStringList("contact-points")).map {
Expand Down Expand Up @@ -192,7 +191,7 @@ object Upcoder extends App with Backend{
Thread.sleep(5000)
// startBackend(2552, "backend")
// Thread.sleep(5000)
startWorker(0)
startWorker()
//startWorker(0)
val conf = ConfigFactory.load
implicit val system = ActorSystem("ClusterSystem", conf)
Expand All @@ -208,5 +207,4 @@ object Upcoder extends App with Backend{
implicit val timeout = Timeout(5.seconds)
// start a new HTTP server on port 8080 with our service actor as the handler
IO(Http) ? Http.Bind(service, interface = "0.0.0.0", port = 9000)
//Http().bind(interface = "0.0.0.0", port = 9000).startHandlingWith(routes)
}
4 changes: 2 additions & 2 deletions src/main/scala/worker/WorkExecutor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ class WorkExecutor extends Actor with ActorLogging{

def getDuration(filePath: String): Int = {
val info = Seq("ffprobe", "-i", filePath, "-show_format", "-loglevel", "quiet")
info.lines.filter(_.contains("duration")).map(_.replace("duration=", "")).mkString.toDouble.toInt
info.lineStream.filter(_.contains("duration")).map(_.replace("duration=", "")).mkString.toDouble.toInt
}

def generateThumbnail(filePath: String, second: Int): File = {
val thumbnailFile = File.createTempFile("thumbnail-", ".jpg")
val thumbnailFilePath = thumbnailFile.getPath
Seq("ffmpeg", "-i", filePath, "-deinterlace", "-an", "-ss", second.toString, "-t", "00:00:01", "-r", "1", "-y", "-vcodec", "mjpeg", "-f", "mjpeg", "-loglevel", "quiet", thumbnailFilePath).!!
Seq("ffmpeg", "-ss", "4", "-i", filePath, "-deinterlace", "-an", "-ss", second.toString, "-t", "00:00:01", "-r", "1", "-y", "-vcodec", "mjpeg", "-f", "mjpeg", "-loglevel", "quiet", thumbnailFilePath).!!
thumbnailFile
}

Expand Down

0 comments on commit 2820353

Please sign in to comment.