Skip to content

Commit

Permalink
Rework env (#833)
Browse files Browse the repository at this point in the history
* more config
- remove unused standard_db config option
- replace all occurences of foo and bar
- simplify tel/env folder structure

* Refactor tel

* rename classes and fix path

* move env creation
- has to be refactored at a later point

* add missing imports

* fix db path

* build improvements

* use sbt shell in docker image

* play 2.7 (#812)

* closes #808, closes #802, closes #803 (#810)

* closes #808

* Cleaner solution for passing env variables

* closes #802

* closes #803

* fix some play 2.7 migration issues (#813)

* now pulled as webjar from npm

* Closes #809 (#814)

* closes #809

* Updated reformat submodule

* akka 2.5.20

* sbt build improvements (#815)

* extracted some bits to project/Settings.scala
* removed unused dependencies

* Setting version to 1.1.11

* Setting version to 1.1.12-SNAPSHOT

* update scalatest (#822)

* set next version

* simplify json parsing code (#825)

* add missing module name (#826)

* remove Env

* stop using a mutable map

* use shared ivy cache

* reformat imports

* remove more occurrences of mutable map

* remove unnecessary implicit

* Remove scalafmt flag

* fix hostname missing

* remove unused imports

* #824, db logic for jobs moved out of controllers
  • Loading branch information
felixgabler authored and vikramalva committed Jun 18, 2019
1 parent 37fd516 commit a0fd35e
Show file tree
Hide file tree
Showing 35 changed files with 128 additions and 397 deletions.
19 changes: 0 additions & 19 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import java.net.InetAddress

import de.proteinevolution.auth.UserSessions
import de.proteinevolution.base.controllers.ToolkitController
import de.proteinevolution.tel.env.Env
import de.proteinevolution.tools.ToolConfig
import javax.inject.{ Inject, Singleton }
import org.webjars.play.WebJarsUtil
Expand All @@ -35,7 +34,6 @@ final class Application @Inject()(
toolConfig: ToolConfig,
userSessions: UserSessions,
cc: ControllerComponents,
env: Env,
environment: Environment,
assetsFinder: AssetsFinder,
config: Configuration
Expand All @@ -44,7 +42,6 @@ final class Application @Inject()(
with Logging {

def index(message: String = ""): Action[AnyContent] = Action.async { implicit request =>
configEnv(request)
userSessions.getUser.map { user =>
logger.info(InetAddress.getLocalHost.getHostName + "\n" + user.toString)
Ok(
Expand Down Expand Up @@ -79,20 +76,4 @@ final class Application @Inject()(
)
}

private def configEnv(request: Request[AnyContent]): Unit = {

env.configure(s"HOSTNAME", config.get[String]("host_name"))

environment.mode match {

case play.api.Mode.Prod =>
val port = "9000"
env.configure("PORT", port)

case _ =>
val port = request.host.slice(request.host.indexOf(":") + 1, request.host.length)
env.configure("PORT", port)
}
}

}
46 changes: 0 additions & 46 deletions app/modules/TELEnvProvider.scala

This file was deleted.

2 changes: 0 additions & 2 deletions app/modules/TELModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
package modules

import com.google.inject.AbstractModule
import de.proteinevolution.tel.env.Env
import de.proteinevolution.tel.param.Params
import com.google.inject.name.Names
import de.proteinevolution.tel.{ ParamCollectorProvider, RunscriptPathProvider, WrapperPathProvider }

class TELModule extends AbstractModule {

override def configure(): Unit = {
bind(classOf[Env]).toProvider(classOf[TELEnvProvider]).asEagerSingleton()
bind(classOf[Params]).toProvider(classOf[ParamCollectorProvider]).asEagerSingleton()
bind(classOf[String])
.annotatedWith(Names.named("runscriptPath"))
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ javaOptions += "-Dplay.editor=http://localhost:63342/api/file/?file=%s&line=%s"
fork in Test := true
logLevel in Test := Level.Info


scalacOptions in Test ++= Seq("-Yrangepos")
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oD")
JsEngineKeys.engineType := JsEngineKeys.EngineType.Node
Expand Down
38 changes: 31 additions & 7 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ include "blacklist"
#Name of the node where the Toolkit is running
host_name = "olt"
host_name = ${?CONFIGURED_HOSTNAME} # beware that $HOSTNAME is a shell variable and cannot be directly used
port = 1234
port = ${?CONFIGURED_PORT}

akka {
jvm-exit-on-fatal-error = false
Expand Down Expand Up @@ -140,6 +142,8 @@ play.mailer {
tls = ${?MAIL_TLS}
user = ${?MAIL_USER}
password = ${?MAIL_PWD}
# custom attribute
template_host = "http://localhost:1234"
}

play.application.loader = ToolkitAppLoader
Expand All @@ -149,11 +153,11 @@ play.allowGlobalApplication = true
####################################################################################

# geoIP
maxmind_db = "/root/GeoLite2-City.mmdb"
maxmind_db = "/root/data/GeoLite2-City.mmdb"
maxmind_db = ${?MAXMIND_DB}

# mongo address with auth for local docker
mongodb.uri = "mongodb://root:rootPassXX@174.18.0.3:27017/tkplay_dev?authenticationDatabase=admin"
mongodb.uri = "mongodb://mongodb:27017/tkplay_dev"
mongodb.uri = ${?MONGODB_URI}

modeller_key = ""
Expand All @@ -172,11 +176,7 @@ bioprogs_root = "/root/Toolkit/bioprogs"

# Set the full path to this file in application-ext.conf
# The SGE nodes will need the full path to source this file.
environment = "tel/env/environment.sh"

helper_scripts = ${bioprogs_root}"/helpers"

perl_lib = ${bioprogs_root}"/lib"
environment = "/root/Toolkit/tel/env/environment.sh"

# Decide whether to submit jobs to the cluster system (sge) or to run them locally (local).
# However, qstat-related functions (e.g. cluster load calculation) will not work in this mode.
Expand All @@ -193,6 +193,30 @@ sge_nodes = "'*'"
# play.mailer.password = ""
# modeller_key = ""
# mongodb.uri = ""
# environment = "" !! absolute path !!

# include extending file with secrets
include "application-ext"

tel.env {
HOSTNAME = ${host_name}
PORT = ${port}
BIOPROGSROOT = ${bioprogs_root}
DATABASES = ${db_root}
SGENODES = ${sge_nodes}
SUBMITMODE = ${submit_mode}

HHSUITE = ${db_root}/hh-suite
UNICLUST = ${db_root}/hhblits/uniclust30
STANDARD = ${db_root}/standard
CIF = ${db_root}/pdb/mmcif/70
CIFALL = ${db_root}/pdb/mmcif/all
HHOMP = ${db_root}/hhomp/db
HHBLITS = ${db_root}/hhblits/
SCOPE = ${db_root}/hh-suite/scope70/pdbEn
ECOD = ${db_root}/hh-suite/ECOD/pdb

ENVIRONMENT = ${environment}
HELPER = ${bioprogs_root}"/helpers"
PERLLIB = ${bioprogs_root}"/lib"
}
2 changes: 1 addition & 1 deletion conf/tel.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configures the tel module of the Toolkit
play.modules.enabled += "modules.TELModule"

tel.env = "tel/env" # must be reconfigured in different environments
tel.env = "tel/env"
tel.params = "tel/paramspec/PARAMS"
tel.types = "tel/types"
tel.runscripts = "tel/runscripts/"
Expand Down
31 changes: 9 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,34 @@ services:
environment:
- SUBMIT_MODE=LOCAL
- SBT_OPTS=-Xms2G -Xmx4G -Xss2M
stdin_open: true
tty: true
# stdin_open: true
# tty: true
ports:
- 1234:1234
- 8080:8080
volumes:
- .:/toolkit
# Uncommenting following 3 lines will speed up sbt boot time significatnly providing you have GeoIP built locally
# - ~/.ivy2:/root/.ivy2
# - ~/.sbt:/root/.sbt
# - ~/.coursier:/root/.coursier
links:
- mongodb
depends_on:
- mongodb
networks:
tk-network:
ipv4_address: 174.18.0.2

# The container for the MongoDB Database
mongodb:
image: mongo:4.0
container_name: tk-mongodb
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/data/log
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=rootPassXX
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/data/log
volumes:
- mongodb:/data/db
ports:
- 27017:27017
command: mongod --auth
networks:
tk-network:
ipv4_address: 174.18.0.3
command: mongod

volumes:
mongodb:

networks:
tk-network:
name: tk-network
driver: bridge
ipam:
driver: default
config:
- subnet: 174.18.0.1/24
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ import de.proteinevolution.auth.models.MailTemplate._
import de.proteinevolution.auth.models.Session.ChangeSessionID
import de.proteinevolution.auth.models.{FormDefinitions, JSONTemplate}
import de.proteinevolution.base.controllers.ToolkitController
import de.proteinevolution.tel.env.Env
import de.proteinevolution.user.{User, UserToken}
import de.proteinevolution.user.{ User, UserToken }
import io.circe.syntax._
import javax.inject.{Inject, Singleton}
import play.api.Logging
import play.api.cache.{NamedCache, SyncCacheApi}
import javax.inject.{ Inject, Singleton }
import play.api.{ Configuration, Logging }
import play.api.libs.mailer.MailerClient
import play.api.mvc.{Action, AnyContent, ControllerComponents}
import reactivemongo.bson.{BSONDateTime, BSONDocument}
Expand All @@ -45,7 +44,7 @@ class AuthController @Inject()(
cc: ControllerComponents,
@NamedCache("wsActorCache") wsActorCache: SyncCacheApi,
environment: play.Environment,
env: Env
config: Configuration,
)(implicit ec: ExecutionContext, mailerClient: MailerClient)
extends ToolkitController(cc)
with JSONTemplate
Expand Down Expand Up @@ -194,7 +193,7 @@ class AuthController @Inject()(
// All done. User is registered, now send the welcome eMail
registeredUser.userToken match {
case Some(token) =>
val eMail = NewUserWelcomeMail(registeredUser, token.token, environment, env)
val eMail = NewUserWelcomeMail(registeredUser, token.token, environment, config)
eMail.send
Ok(signedUp)
case None => Ok(tokenMismatch())
Expand Down Expand Up @@ -249,7 +248,7 @@ class AuthController @Inject()(
case Some(registeredUser) =>
// All done. User is registered, now send the welcome eMail
val eMail =
ResetPasswordMail(registeredUser, token.token, environment: play.Environment, env: Env)
ResetPasswordMail(registeredUser, token.token, environment: play.Environment, config)
eMail.send
Ok(passwordRequestSent)
case None =>
Expand Down Expand Up @@ -299,7 +298,7 @@ class AuthController @Inject()(
.map {
case Some(updatedUser) =>
// All done. Now send the eMail to notify the user that the password has been changed
val eMail = PasswordChangedMail(updatedUser, environment: play.Environment, env: Env)
val eMail = PasswordChangedMail(updatedUser, environment, config)
eMail.send
Ok(passwordChanged(updatedUser))
case None =>
Expand Down Expand Up @@ -350,7 +349,7 @@ class AuthController @Inject()(
userSessions.modifyUserWithCache(selector, modifier).map {
case Some(updatedUser) =>
// All done. Now send the eMail
val eMail = ChangePasswordMail(updatedUser, token.token, environment: play.Environment, env: Env)
val eMail = ChangePasswordMail(updatedUser, token.token, environment: play.Environment, config)
eMail.send
// Everything is ok, let the user know that they are logged in now
Ok(passwordChanged(updatedUser))
Expand Down
Loading

0 comments on commit a0fd35e

Please sign in to comment.