Skip to content

Commit

Permalink
Modifying the start-rpm-template and LinuxPlugin such that where the …
Browse files Browse the repository at this point in the history
…defaultLinuxLogsLocation is overridden the deamon log will be assigned to this overridden location. This was causing an issue given that the rpm would create the log location at the new location, but the daemon was still logging in the default location which was not created by the rpm. Tested on CENTOS 6.7

Added test coverage for defaultLinuxInstallLocation and defaultLinuxLogsLocation for init.d files generated upon creation of rpm
  • Loading branch information
louisq committed Oct 6, 2015
1 parent bf173d5 commit 3fda991
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exec="$INSTALL_DIR/bin/${{exec}}"
prog="${{app_name}}"
lockfile="/var/lock/subsys/${{app_name}}"

RUN_CMD="$exec >> /var/log/${{app_name}}/${{rpm_daemon_log_file}} 2>&1 &"
RUN_CMD="$exec >> ${{logdir}}/${{app_name}}/${{rpm_daemon_log_file}} 2>&1 &"

# $JAVA_OPTS used in $exec wrapper
export JAVA_OPTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ object LinuxPlugin extends AutoPlugin {
description = (packageSummary in Linux).value,
execScript = (executableScriptName in Linux).value,
chdir = s"${defaultLinuxInstallLocation.value}/${(packageName in Linux).value}",
logdir = defaultLinuxLogsLocation.value,
appName = (packageName in Linux).value,
version = sbt.Keys.version.value,
daemonUser = (daemonUser in Linux).value,
Expand Down Expand Up @@ -155,6 +156,7 @@ object LinuxPlugin extends AutoPlugin {
description: String,
execScript: String,
chdir: String,
logdir: String,
appName: String,
version: String,
daemonUser: String,
Expand All @@ -172,6 +174,7 @@ object LinuxPlugin extends AutoPlugin {
"descr" -> description,
"exec" -> execScript,
"chdir" -> chdir,
"logdir" -> logdir,
"retries" -> retries.toString,
"retryTimeout" -> retryTimeout.toString,
"app_name" -> appName,
Expand Down
40 changes: 40 additions & 0 deletions src/sbt-test/rpm/path-override-rpm/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
enablePlugins(JavaServerAppPackaging)

name := "rpm-test"

version := "0.1.0"

maintainer := "Josh Suereth <joshua.suereth@typesafe.com>"

packageSummary := "Test rpm package"

executableScriptName := "rpm-exec"

packageDescription := """A fun package description of our software,
with multiple lines."""

rpmRelease := "1"

rpmVendor := "typesafe"

rpmUrl := Some("http://github.com/sbt/sbt-native-packager")

rpmLicense := Some("BSD")

defaultLinuxInstallLocation := "/opt/test"

defaultLinuxLogsLocation := "/opt/test/log"

TaskKey[Unit]("unzip") <<= (baseDirectory, packageBin in Rpm, streams) map { (baseDir, rpmFile, streams) =>
val rpmPath = Seq(rpmFile.getAbsolutePath)
Process("rpm2cpio" , rpmPath) #| Process("cpio -i --make-directories") ! streams.log
()
}

TaskKey[Unit]("check-init-file") <<= (baseDirectory, streams) map { (target, out) =>
val initd = IO.read(target / "etc" / "init.d" / "rpm-test")
assert(initd contains "/opt/test/rpm-test", "defaultLinuxInstallLocation not overriden in init.d\n" + initd)
assert(initd contains "/opt/test/log/rpm-test/rpm-test.log", "defaultLinuxLogsLocation not overriden in init.d\n" + initd)
out.log.success("Successfully tested rpm-test file")
()
}
1 change: 1 addition & 0 deletions src/sbt-test/rpm/path-override-rpm/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
10 changes: 10 additions & 0 deletions src/sbt-test/rpm/path-override-rpm/src/main/scala/test/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package test

object Main {
def main (args: Array[String]) {
//server app imitation
while (true){
Thread.sleep(1000L)
}
}
}
10 changes: 10 additions & 0 deletions src/sbt-test/rpm/path-override-rpm/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Run the rpm packaging.
> rpm:package-bin
$ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm

> unzip
$ exists opt/test/rpm-test

$ exists etc/init.d/rpm-test
> check-init-file

0 comments on commit 3fda991

Please sign in to comment.