Prepare for deployment

This commit is contained in:
folex 2019-06-16 12:27:56 +02:00
parent 4cb583810c
commit de17414d2c
4 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import org.apache.ivy.core.module.descriptor.License import org.apache.ivy.core.module.descriptor.License
import sbtassembly.{MergeStrategy, PathList}
name := "http-scala-api" name := "http-scala-api"
@ -15,6 +16,9 @@ resolvers += Resolver.bintrayRepo("fluencelabs", "releases")
scalacOptions ++= Seq("-Ypartial-unification", "-deprecation") scalacOptions ++= Seq("-Ypartial-unification", "-deprecation")
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.0") addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.0")
assemblyMergeStrategy in assembly := strategy.value
libraryDependencies ++= Seq( libraryDependencies ++= Seq(
fs2, fs2,
fs2rx, fs2rx,
@ -61,3 +65,13 @@ val circeFs2 = "io.circe" %% "circe-fs2" % "0.11.0"
val catsVersion = "1.6.0" val catsVersion = "1.6.0"
val cats = "org.typelevel" %% "cats-core" % catsVersion val cats = "org.typelevel" %% "cats-core" % catsVersion
val catsEffect = "org.typelevel" %% "cats-effect" % "1.3.0" val catsEffect = "org.typelevel" %% "cats-effect" % "1.3.0"
val strategy = Def.setting[String => MergeStrategy]({
// a module definition fails compilation for java 8, just skip it
case PathList("module-info.class", xs @ _*) => MergeStrategy.first
case "META-INF/io.netty.versions.properties" => MergeStrategy.first
case x =>
import sbtassembly.AssemblyPlugin.autoImport.assembly
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}: String => MergeStrategy)

2
project/plugins.sbt Normal file
View File

@ -0,0 +1,2 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")

View File

@ -145,7 +145,7 @@ class AppRegistry[F[_]: Monad: Concurrent: ContextShift: Timer: LiftIO](
new Exception(s"Failed to decode binary hash from base64: $e"): Throwable)) new Exception(s"Failed to decode binary hash from base64: $e"): Throwable))
binaryPath = baseDir.resolve("binary") binaryPath = baseDir.resolve("binary")
_ <- fetchTo(binaryHash, binaryPath).leftMap(identity[Throwable]) _ <- ipfsFetch(binaryHash, binaryPath).leftMap(identity[Throwable])
_ <- log(s"$name binary downloaded $binaryPath") _ <- log(s"$name binary downloaded $binaryPath")
status <- status(name, peer) status <- status(name, peer)
@ -244,7 +244,7 @@ class AppRegistry[F[_]: Monad: Concurrent: ContextShift: Timer: LiftIO](
max = 10 max = 10
) )
private def fetchTo(hash: ByteVector, private def ipfsFetch(hash: ByteVector,
dest: Path): EitherT[F, IpfsError, Unit] = { dest: Path): EitherT[F, IpfsError, Unit] = {
ipfsStore ipfsStore
.fetch(hash) .fetch(hash)

View File

@ -96,7 +96,7 @@ case class WebsocketServer[F[_]: ConcurrentEffect: Timer: ContextShift](
for { for {
exitCode <- Stream.eval(Ref[F].of(ExitCode.Success)) exitCode <- Stream.eval(Ref[F].of(ExitCode.Success))
server <- BlazeServerBuilder[F] server <- BlazeServerBuilder[F]
.bindHttp(port) .bindHttp(port, "0.0.0.0")
.withHttpApp(CORS[F, F](routes().orNotFound, corsConfig)) .withHttpApp(CORS[F, F](routes().orNotFound, corsConfig))
.serveWhile(signal, exitCode) .serveWhile(signal, exitCode)
} yield server } yield server