Skip to content

Commit

Permalink
#193 Fix log file location in development mode
Browse files Browse the repository at this point in the history
rename install folder in package
  • Loading branch information
To-om committed May 8, 2017
1 parent 6e712b6 commit d5aaff3
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 14 deletions.
28 changes: 15 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ mappings in Universal ~= {
_.flatMap {
case (file, "conf/application.conf") => Nil
case (file, "conf/application.sample") => Seq(file -> "conf/application.conf")
case (file, "conf/logback.xml") => Nil
case other => Seq(other)
} ++ Seq(
file("install/thehive.service") -> "install/thehive.service",
file("install/thehive.conf") -> "install/thehive.conf",
file("install/thehive") -> "install/thehive"
file("package/thehive.service") -> "package/thehive.service",
file("package/thehive.conf") -> "package/thehive.conf",
file("package/thehive") -> "package/thehive",
file("package/logback.xml") -> "conf/logback.xml"
)
}

Expand All @@ -59,13 +61,13 @@ packageDescription := """TheHive is a scalable 3-in-1 open source and free secur
defaultLinuxInstallLocation := "/opt"
linuxPackageMappings ~= { _.map { pm =>
val mappings = pm.mappings.filterNot {
case (file, path) => path.startsWith("/opt/thehive/install") || path.startsWith("/opt/thehive/conf")
case (file, path) => path.startsWith("/opt/thehive/package") || path.startsWith("/opt/thehive/conf")
}
com.typesafe.sbt.packager.linux.LinuxPackageMapping(mappings, pm.fileData).withConfig()
} :+ packageMapping(
file("install/thehive.service") -> "/etc/systemd/system/thehive.service",
file("install/thehive.conf") -> "/etc/init/thehive.conf",
file("install/thehive") -> "/etc/init.d/thehive",
file("package/thehive.service") -> "/etc/systemd/system/thehive.service",
file("package/thehive.conf") -> "/etc/init/thehive.conf",
file("package/thehive") -> "/etc/init.d/thehive",
file("conf/application.sample") -> "/etc/thehive/application.conf",
file("conf/logback.xml") -> "/etc/thehive/logback.xml"
).withConfig()
Expand All @@ -80,10 +82,10 @@ packageBin := {
debianPackageRecommends := Seq("elasticsearch")
debianPackageDependencies += "java8-runtime-headless | java8-runtime"
maintainerScripts in Debian := maintainerScriptsFromDirectory(
baseDirectory.value / "install" / "debian",
baseDirectory.value / "package" / "debian",
Seq(DebianConstants.Postinst, DebianConstants.Prerm, DebianConstants.Postrm)
)
linuxEtcDefaultTemplate in Debian := (baseDirectory.value / "install" / "etc_default_thehive").asURL
linuxEtcDefaultTemplate in Debian := (baseDirectory.value / "package" / "etc_default_thehive").asURL
linuxMakeStartScript in Debian := None

// RPM //
Expand All @@ -93,12 +95,12 @@ rpmUrl := Some("http://thehive-project.org/")
rpmLicense := Some("AGPL")
rpmRequirements += "java-1.8.0-openjdk-headless"
maintainerScripts in Rpm := maintainerScriptsFromDirectory(
baseDirectory.value / "install" / "rpm",
baseDirectory.value / "package" / "rpm",
Seq(RpmConstants.Pre, RpmConstants.Preun, RpmConstants.Postun)
)
linuxPackageSymlinks in Rpm := Nil
rpmPrefix := Some(defaultLinuxInstallLocation.value)
linuxEtcDefaultTemplate in Rpm := (baseDirectory.value / "install" / "etc_default_thehive").asURL
linuxEtcDefaultTemplate in Rpm := (baseDirectory.value / "package" / "etc_default_thehive").asURL

// DOCKER //
import com.typesafe.sbt.packager.docker.{ Cmd, ExecCmd }
Expand All @@ -109,9 +111,9 @@ dockerUpdateLatest := true
dockerEntrypoint := Seq("/opt/thehive/entrypoint")
dockerExposedPorts := Seq(9000)
mappings in Docker ++= Seq(
file("install/docker/entrypoint") -> "/opt/thehive/entrypoint",
file("package/docker/entrypoint") -> "/opt/thehive/entrypoint",
file("conf/logback.xml") -> "/etc/thehive/logback.xml",
file("install/empty") -> "/var/log/thehive/application.log")
file("package/empty") -> "/var/log/thehive/application.log")
mappings in Docker ~= (_.filterNot {
case (_, filepath) => filepath == "/opt/thehive/conf/application.conf"
})
Expand Down
2 changes: 1 addition & 1 deletion conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
converterClass="play.api.libs.logback.ColoredLevel" />

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>/var/log/thehive/application.log</file>
<file>${application.home:-.}/logs/application.log</file>
<encoder>
<pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
</encoder>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions package/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">

<conversionRule conversionWord="coloredLevel"
converterClass="play.api.libs.logback.ColoredLevel" />

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>/var/log/thehive/application.log</file>
<encoder>
<pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
</encoder>
</appender>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %logger{15} - %message%n%xException{10}
</pattern>
</encoder>
</appender>

<appender name="ASYNCFILE" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="FILE" />
</appender>

<appender name="ASYNCSTDOUT" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="STDOUT" />
</appender>

<logger name="play" level="INFO" />
<logger name="application" level="INFO" />

<logger name="com.gargoylesoftware.htmlunit.javascript" level="OFF" />

<root level="INFO">
<appender-ref ref="ASYNCFILE" />
<appender-ref ref="ASYNCSTDOUT" />
</root>

</configuration>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d5aaff3

Please sign in to comment.