From 3df9811e88f57ff12bc22da7153d165f8cc02789 Mon Sep 17 00:00:00 2001 From: andrewresearch Date: Wed, 2 Aug 2017 17:19:31 +1000 Subject: [PATCH] goingok-server-14 Need a version api that can be called by the client --- README.md | 4 +- build.sbt | 50 +++++++++---------- .../org/goingok/data/models/ServerInfo.scala | 11 ++++ .../org/goingok/httpServer/GoingOkAPI.scala | 14 +++++- .../scala/org/goingok/httpServer/Server.scala | 2 + 5 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 src/main/scala/org/goingok/data/models/ServerInfo.scala diff --git a/README.md b/README.md index 1e92c4a..ecc4237 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -[![Build Status](https://travis-ci.org/GoingOK/goingok-server.svg?branch=master)](https://travis-ci.org/GoingOK/goingok-server) [ ![bintray](https://api.bintray.com/packages/nlytx/nlytx_commons/nlytx_commons/images/download.svg?version=0.1.1) ](https://bintray.com/nlytx/nlytx_commons/nlytx_commons/0.1.1/link) [![https://img.shields.io/badge/license-Apache%202.0-blue.svg](https://img.shields.io/badge/license-Apache%202.0-lightgrey.svg)](http://www.apache.org/licenses/LICENSE-2.0) +[![Build Status](https://travis-ci.org/GoingOK/goingok-server.svg?branch=master)](https://travis-ci.org/GoingOK/goingok-server) + +[![https://img.shields.io/badge/license-Apache%202.0-blue.svg](https://img.shields.io/badge/license-Apache%202.0-lightgrey.svg)](http://www.apache.org/licenses/LICENSE-2.0) # goingok-server diff --git a/build.sbt b/build.sbt index e57600c..0d9def2 100644 --- a/build.sbt +++ b/build.sbt @@ -1,22 +1,22 @@ name := "goingok-server" -version := "1.0.0" -scalaVersion := "2.12.2" +version := "1.0.1" +scalaVersion := "2.12.3" organization := "org.goingok" +//Enable this only for local builds - disabled for Travis //enablePlugins(JavaAppPackaging) //Scala library versions -val akkaVersion = "2.5.1" -val akkaStreamVersion = "2.5.1" -val akkaHttpVersion = "10.0.6" -val json4sVersion = "3.5.1" -val slickVersion = "3.2.0" -val slickpgVersion = "0.15.0-RC" +val akkaVersion = "2.5.3" +val akkaStreamVersion = "2.5.3" +val akkaHttpVersion = "10.0.9" +val json4sVersion = "3.5.3" +val slickVersion = "3.2.1" +val slickpgVersion = "0.15.3" val slf4jVersion = "1.7.25" //Java library versions val googleClientApiVersion = "1.22.0" -val postgresDriverVersion = "42.0.0" -//val coreNlpVersion = "3.7.0" +val postgresDriverVersion = "42.1.4" //Akka libraryDependencies ++= Seq( @@ -30,17 +30,10 @@ libraryDependencies ++= Seq( libraryDependencies += "com.google.api-client" % "google-api-client" % googleClientApiVersion //Sessions libraryDependencies ++= Seq( - "com.softwaremill.akka-http-session" %% "core" % "0.4.0", - "com.softwaremill.akka-http-session" %% "jwt" % "0.4.0" -) -//NLP dependencies -libraryDependencies ++= Seq( - //"edu.stanford.nlp" % "stanford-corenlp" % coreNlpVersion, - //"edu.stanford.nlp" % "stanford-corenlp" % coreNlpVersion classifier "models-english" //, - //"com.google.protobuf" % "protobuf-java" % protoBufVers, - //("org.languagetool" % "language-en" % languageToolVers) - // .exclude("commons-logging", "commons-logging") + "com.softwaremill.akka-http-session" %% "core" % "0.5.1", + "com.softwaremill.akka-http-session" %% "jwt" % "0.5.1" ) + //Slick libraryDependencies ++= Seq( "com.typesafe.slick" %% "slick" % slickVersion, @@ -52,17 +45,22 @@ libraryDependencies ++= Seq( //General libraryDependencies ++= Seq( "io.nlytx" %% "commons" % "0.1.1", -// "au.edu.utscic" %% "cic-tap-nlp" % "0.1", -// "au.edu.utscic" %% "cic-tap-aws" % "0.1", // "com.typesafe" % "config" % "1.3.1", "org.json4s" %% "json4s-jackson" % json4sVersion, - "de.heikoseeberger" %% "akka-http-json4s" % "1.11.0", + "de.heikoseeberger" %% "akka-http-json4s" % "1.17.0", // "org.scalactic" %% "scalactic" % "3.0.0", - "org.scalatest" %% "scalatest" % "3.0.0" % "test", + "org.scalatest" %% "scalatest" % "3.0.3" % "test", "org.slf4j" % "jcl-over-slf4j" % slf4jVersion, - "ch.qos.logback" % "logback-classic" % "1.1.7" + "ch.qos.logback" % "logback-classic" % "1.2.3" ) scalacOptions in (Compile, doc) ++= Seq("-doc-root-content", baseDirectory.value+"/src/main/scala/root-doc.md") -resolvers += Resolver.bintrayRepo("nlytx", "nlytx_commons") \ No newline at end of file +resolvers += Resolver.bintrayRepo("nlytx", "nlytx_commons") + +//Generate build info file +//lazy val root = (project in file(".")). +enablePlugins(BuildInfoPlugin) + buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion) + buildInfoPackage := "org.goingok" + buildInfoOptions += BuildInfoOption.BuildTime diff --git a/src/main/scala/org/goingok/data/models/ServerInfo.scala b/src/main/scala/org/goingok/data/models/ServerInfo.scala new file mode 100644 index 0000000..43b39b2 --- /dev/null +++ b/src/main/scala/org/goingok/data/models/ServerInfo.scala @@ -0,0 +1,11 @@ +package org.goingok.data.models + +/** + * Created by andrew@andrewresearch.net on 2/8/17. + */ + +case class ServerInfo( + name:String, + version:String, + buildTime:String + ) diff --git a/src/main/scala/org/goingok/httpServer/GoingOkAPI.scala b/src/main/scala/org/goingok/httpServer/GoingOkAPI.scala index 548335b..baaa824 100644 --- a/src/main/scala/org/goingok/httpServer/GoingOkAPI.scala +++ b/src/main/scala/org/goingok/httpServer/GoingOkAPI.scala @@ -7,7 +7,7 @@ import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.model.headers.RawHeader import com.softwaremill.session.{SessionConfig, SessionManager} import org.goingok._ -import org.goingok.data.models.{GokId, ReflectionEntry, Research} +import org.goingok.data.models.{GokId, ReflectionEntry, Research, ServerInfo} import org.goingok.handlers.{AuthorisationHandler, ProfileHandler} import org.goingok.message.{HandlerMessage, JsonMessage} import org.json4s.JsonAST.JString @@ -113,5 +113,17 @@ trait GoingOkAPI extends GenericApi { } + lazy val serverInfo = ServerInfo(BuildInfo.name,BuildInfo.version,BuildInfo.builtAtString) + + override val adminRoutes = pathPrefix("admin") { + path("version") { + get { + log.info("Version request") + complete(serverInfo) + } + } ~ + get { nothingHere } + } + } diff --git a/src/main/scala/org/goingok/httpServer/Server.scala b/src/main/scala/org/goingok/httpServer/Server.scala index bb5a141..6f1a04b 100644 --- a/src/main/scala/org/goingok/httpServer/Server.scala +++ b/src/main/scala/org/goingok/httpServer/Server.scala @@ -1,6 +1,7 @@ package org.goingok.httpServer import akka.http.scaladsl.Http +import org.goingok.BuildInfo import org.goingok.data.persistence.db.DatabaseOps import scala.util.{Failure, Success} @@ -24,6 +25,7 @@ object Server extends GoingOkAPI { var dbOk = false def startServer(address:String, port:Int) = { + log.info("->> STARTING {} - version {} <<-",BuildInfo.name,BuildInfo.version) log.info("Connecting to DB server") connectDb log.info("Starting http server at {}:{}",address,port)