Unverified Commit bcd0fc10 authored by Romain Reuillon's avatar Romain Reuillon
Browse files

[dbServer] enh: fix args properly.

parent ede7e2a0
......@@ -221,8 +221,8 @@ lazy val scalajHttp = OsgiProject(dir, "org.scalaj.scalaj-http") settings(
) settings(settings: _*)
lazy val scopt = OsgiProject(dir, "com.github.scopt", exports = Seq("scopt.*")) settings(
libraryDependencies += "com.github.scopt" %% "scopt" % "3.2.0",
version := "3.2.0"
libraryDependencies += "com.github.scopt" %% "scopt" % "3.5.0",
version := "3.5.0"
) settings(settings: _*)
lazy val scalabc = OsgiProject(dir, "fr.iscpif.scalabc", privatePackages = Seq("!scala.*", "!junit.*", "*")) settings(
......
......@@ -56,7 +56,10 @@ while [[ $# -gt 0 ]]; do
shift
done
(nohup sh $LOCATION/dbserver/bin/openmole-dbserver $WORKSPACE >/dev/null &) 2>/dev/null
if [ -z $WORKSPACE ];
then (nohup sh $LOCATION/dbserver/bin/openmole-dbserver >/dev/null &) 2>/dev/null
else (nohup sh $LOCATION/dbserver/bin/openmole-dbserver -w "${WORKSPACE}" >/dev/null &) 2>/dev/null
fi
SCRIPT_ARGS=()
......
......@@ -25,17 +25,30 @@ import java.io.FileOutputStream
import java.util.UUID
import org.h2.tools.Server
import slick.driver.H2Driver.api._
import slick.jdbc.H2Profile.api._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.util.{ Failure, Success, Try }
import org.openmole.core.db
import org.openmole.core.db.{ DBServerInfo, DBServerRunning, Replica }
import org.openmole.core.workspace.NewFile
import scopt._
import org.openmole.tool.file._
object DBServer extends App {
val base = if (!args.isEmpty) new File(args(0)) else db.defaultOpenMOLEDirectory
case class Config(workspace: Option[String] = None)
val parser = new OptionParser[Config]("OpenMOLE") {
head("OpenMOLE database server", "0.x")
opt[String]('w', "workspace") text ("workspace location") action {
(v, c) c.copy(workspace = Some(v))
}
}
val config = parser.parse(args, Config()).getOrElse(throw new RuntimeException("Incorrect arguments: \n" + parser.usage))
val base = config.workspace.map(w new File(w)).getOrElse(db.defaultOpenMOLEDirectory)
def checkInterval = 30000
def maxAllDead = 5
......@@ -109,8 +122,14 @@ object DBServer extends App {
if (!dbWorks) createDB(info.user, info.password)
val out = new FileOutputStream(db.dbInfoFile(dbDirectory))
try new XStream().toXML(info, out) finally out.close
val newFile = NewFile(dbDirectory)
newFile.withTmpFile { tmp
tmp.withFileOutputStream { os new XStream().toXML(info, os) }
val destination = db.dbInfoFile(dbDirectory)
tmp move destination
destination
}
def waitAllDead(count: Int): Unit = {
Logger.getLogger(getClass.getName).info(s"Waiting $count times for all OpenMOLE to be dead.")
......
......@@ -171,7 +171,7 @@ lazy val replication = OsgiProject(coreDir, "org.openmole.core.replication", imp
libraryDependencies ++= Seq(Libraries.slick, Libraries.xstream, Libraries.guava)) settings (coreSettings: _*) dependsOn(db, preference)
lazy val db = OsgiProject(coreDir, "org.openmole.core.db", imports = Seq("*")) settings(bundleType += "dbserver",
libraryDependencies ++= Seq(Libraries.slick, Libraries.xstream, Libraries.h2)) settings (coreSettings: _*) dependsOn(openmoleNetwork, workspace, exception, openmoleCrypto)
libraryDependencies ++= Seq(Libraries.slick, Libraries.xstream, Libraries.h2, Libraries.scopt)) settings (coreSettings: _*) dependsOn(openmoleNetwork, workspace, exception, openmoleCrypto)
lazy val preference = OsgiProject(coreDir, "org.openmole.core.preference", imports = Seq("*")) settings(
libraryDependencies ++= Seq(Libraries.configuration, Libraries.scalaLang, Libraries.squants)) settings (coreSettings: _*) dependsOn(openmoleNetwork, openmoleCrypto, openmoleFile, openmoleThread, openmoleTypes, openmoleLock, exception)
......
......@@ -49,7 +49,7 @@ object Libraries {
lazy val opencsv = "org.openmole.library" %% "au-com-bytecode-opencsv" % "2.3"
lazy val arm = "org.openmole.library" %% "com-jsuereth-scala-arm" % "1.4"
lazy val scalajHttp = "org.openmole.library" %% "org-scalaj-scalaj-http" % "0.3.15"
lazy val scopt = "org.openmole.library" %% "com-github-scopt" % "3.2.0"
lazy val scopt = "org.openmole.library" %% "com-github-scopt" % "3.5.0"
lazy val scalabc = "org.openmole.library" %% "fr-iscpif-scalabc" % "0.4"
lazy val scalatexSite = "org.openmole.library" %% "com-lihaoyi-scalatex-site" % "0.3.6"
lazy val math = "org.openmole.library" %% "org-apache-commons-math" % "3.6.1"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment