magegu
magegu

Reputation: 530

Setup logging/config for production with deb file and SBT

I'm search for the best way way to set up my logging/config in production within my deb file using the sbt-native-packager.

a.) I want to copy my reference.conf and logback.xml from my code repository to /etc/my-app/reference.conf or /etc/my-app/logback.xml. I guess its somehow possible with linuxPackageMappings but i could'nt find a example yet and I'm still struggling to get how SBT and the plugings work together.

b.) I need to tell my jvm that i should use this config and this logback config when started via the created upstart - how do I pass parameters from the build.scala to the jvm-runscript

this is my current project val:

lazy val root = Project(id = appName, base = file("."), settings = JavaServerAppPackaging.settings  ++ packageSettings ++ allSettings ++ Project.defaultSettings)

  lazy val allSettings = Seq(
    resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases",
    resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
    libraryDependencies ++= dependencies)

  lazy val packageSettings = packageArchetype.java_server ++ Seq(
    bashScriptExtraDefines := Seq("aha"),
    version := appVersion,
    packageSummary := appName,
    packageDescription := appName,
    maintainer := appAuthor,    
    debianPackageDependencies in Debian ++= Seq("openjdk-7-jre-headless"))

thanks

Upvotes: 3

Views: 876

Answers (2)

Muki
Muki

Reputation: 3641

a) For logging output see this question. Configuration input can be done easily with

mappings in Universal <+= (packageBin in Compile, baseDirectory ) map { (_, base) =>
    val conf = base / "conf" / "reference.conf"
    conf -> "conf/application.conf"
} 

By convention the Universal packaging defines config files in the conf folder. For debian this automatically mapped to /etc/your-app/filename

b) Passing parameters to the script is also done via a config file. Use 0.7.0-M3 and follow the instructions here and take a look at the etc-default template

Upvotes: 2

Mark
Mark

Reputation: 477

Lots of questions mixed in hear...

a) So to you can install your conf and xml files by including them in your debian package. Building debian packages is not built in to sbt out of the box. You could try https://github.com/sbt/sbt-native-packager but you may be better of dropping out of sbt and just using one of the many normal ways to create debian packages.

Note that you should not be logging to /etc on a linux box. Logs should go under /var

b) you can install an init script that has -D peramiters to tell play where to find its conf and logback.xml files.

$JAVA_HOME/bin/java -Dconfig.file=/etc/foo.comf -Dlogger.file=/etc/logger.xml

c) you should be logging to some directory under /var

You can create directories in the postinst script that is part of the debian package. puppet (or something similar) can be a better way to manage config files on deployed boxes though.

Upvotes: 0

Related Questions