Skip to content

Commit

Permalink
symlink the db folder in hotspot mode
Browse files Browse the repository at this point in the history
hardcode version for akka
  • Loading branch information
araspitzu committed May 4, 2018
1 parent 5010d96 commit cb5ad1c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
20 changes: 17 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ val env = sys.props.getOrElse("env", default = "local")
val buildVersion = sys.props.getOrElse("version", default = "0.0.1")
val buildName = "btc-hotspot"

val akkaVersion = "2.4.20"
val akkaVersion = "2.5.11"
val akkaHttpVersion = "10.+"
val json4sVersion = "3.+"

Expand Down Expand Up @@ -44,7 +44,7 @@ lazy val btc_hotspot = (project in file(".")).
//JSON4S
"org.json4s" %% "json4s-native" % json4sVersion,
"org.json4s" %% "json4s-ext" % json4sVersion,
"de.heikoseeberger" %% "akka-http-json4s" % "1.+",
"de.heikoseeberger" %% "akka-http-json4s" % "1.20.1",

//LOGGING
"ch.qos.logback" % "logback-classic" % "1.2.3",
Expand Down Expand Up @@ -106,7 +106,9 @@ lazy val universalPluginSettings = Seq(
confFileMapping.value,
logbackConfMapping.value
)
}
},
databaseDirectory,
databaseDirSymlink
)


Expand All @@ -126,6 +128,18 @@ lazy val confFileMapping = Def.setting {
conf -> "conf/application.conf"
}

lazy val databaseDirectory = {
linuxPackageMappings += packageTemplateMapping(
s"/opt/$buildName/database"
)().withUser((daemonUser in Linux).value)
.withGroup((daemonGroup in Linux).value)
.withPerms("755")
}


lazy val databaseDirSymlink = linuxPackageSymlinks += {
LinuxSymlink(s"$targetDirectory/database", s"/opt/$buildName/database")
}

lazy val scalariformPref = Def.setting {
ScalariformKeys.preferences.value
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/hotspot.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ database {
webUI = true
profile = "slick.jdbc.H2Profile$"
db {
url = "jdbc:h2::~/:btc-hotspot-db;DB_CLOSE_DELAY=-1"
url = "jdbc:h2:./database/files:btc-hotspot-db;DB_CLOSE_DELAY=-1"
driver = org.h2.Driver
connectionPool = disabled
keepAliveConnection = true
Expand Down
11 changes: 8 additions & 3 deletions src/main/scala/services/SessionServiceImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,17 @@ class SessionServiceImpl(dependencies: {

def disableSession(session: Session): FutureOption[Unit] = {
logger.info(s"Disabling session ${session}")
val stopWatch = sessionIdToStopwatch.get(session.id).getOrElse {
throw new IllegalArgumentException(s"session ${session.id} has no stopwatch attached")
}

for {
_ <- sessionRepository.upsert(session.copy(offerId = None))
stopWatch <- FutureOption(Future.successful(sessionIdToStopwatch.get(session.id)))
stopped <- stopWatch.stop()
upserted <- sessionRepository.upsert(session.copy(offerId = None)) orFailWith s"Error upserting session ${session.id}"
} yield {
stopWatch.stop()

sessionIdToStopwatch.remove(session.id)
Some(())
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/scala/watchdog/StopWatch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class TimebasedStopWatch(val dependencies: {
}

override def stop(): Future[Unit] = {
logger.info(s"stopwatch for session ${session.id} is stopping")
ipTablesService.disableClient(session.clientMac) map { ipTablesOut =>
// abort scheduled task
if (isPending) {
Expand Down

0 comments on commit cb5ad1c

Please sign in to comment.