Skip to content

Commit

Permalink
Merge pull request #105 from muuki88/wip_starting_dir
Browse files Browse the repository at this point in the history
Setting chdir to application directory.
  • Loading branch information
jsuereth committed Dec 11, 2013
2 parents 12f93d9 + 9f3c8f6 commit 85c0b23
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ start on runlevel [2345]
respawn
respawn limit ${{retries}} ${{retryTimeout}}

# TODO - this wasn't working on my ubuntu...
# set the working directory of the job processes
#chdir ${{chdir}}
chdir ${{chdir}}

# Start the process
script
cd ${{chdir}}
exec ${{exec}}
exec ./bin/${{exec}}
end script
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Keys._
import sbt._
import sbt.Keys.{ target, mainClass, normalizedName }
import SbtNativePackager._
import com.typesafe.sbt.packager.linux.{LinuxFileMetaData, LinuxPackageMapping}
import com.typesafe.sbt.packager.linux.{ LinuxFileMetaData, LinuxPackageMapping, LinuxSymlink }

/**
* This class contains the default settings for creating and deploying an archetypical Java application.
Expand All @@ -27,47 +27,51 @@ object JavaServerAppPackaging {
Seq(
debianStartScriptReplacements <<= (
maintainer in Debian, packageSummary in Debian, serverLoading in Debian, daemonUser in Debian, normalizedName,
sbt.Keys.version, defaultLinuxInstallLocation, mainClass in Compile, scriptClasspath)
sbt.Keys.version, defaultLinuxInstallLocation, mainClass in Compile, scriptClasspath)
map { (author, descr, loader, daemonUser, name, version, installLocation, mainClass, cp) =>
// TODO name-version is copied from UniversalPlugin. This should be consolidated into a setting (install location...)
val appDir = installLocation + "/" + name
val chdir = appDir + "/bin"
val appClasspath = cp.map(appDir + "/lib/" + _).mkString(":")
// TODO name-version is copied from UniversalPlugin. This should be consolidated into a setting (install location...)
val appDir = installLocation + "/" + name
val appClasspath = cp.map(appDir + "/lib/" + _).mkString(":")

JavaAppStartScript.makeReplacements(
author = author,
description = descr,
execScript = name,
chdir = chdir,
appName = name,
appClasspath = appClasspath,
appMainClass = mainClass.get,
daemonUser = daemonUser
)
},
JavaAppStartScript.makeReplacements(
author = author,
description = descr,
execScript = name,
chdir = appDir,
appName = name,
appClasspath = appClasspath,
appMainClass = mainClass.get,
daemonUser = daemonUser)
},
debianMakeStartScript <<= (debianStartScriptReplacements, normalizedName, target in Universal, serverLoading in Debian)
map makeDebianStartScript,
debianMakeEtcDefault <<= (normalizedName, target in Universal, serverLoading in Debian)
map makeEtcDefaultScript,
linuxPackageMappings in Debian <++= (debianMakeEtcDefault, normalizedName) map {(conf, name) =>
linuxPackageMappings in Debian <++= (debianMakeEtcDefault, normalizedName) map { (conf, name) =>
conf.map(c => LinuxPackageMapping(Seq(c -> s"/etc/default/$name")).withConfig()).toSeq
},
linuxPackageMappings in Debian <++= (debianMakeStartScript, normalizedName, serverLoading in Debian)
map { (script, name, loader) =>
val (path, permissions) = loader match {
case Upstart => ("/etc/init/" + name + ".conf", "0644")
case SystemV => ("/etc/init.d/" + name, "0755")
}
val (path, permissions) = loader match {
case Upstart => ("/etc/init/" + name + ".conf", "0644")
case SystemV => ("/etc/init.d/" + name, "0755")
}

for {
s <- script.toSeq
} yield LinuxPackageMapping(Seq(s -> path)).withPerms(permissions)
for {
s <- script.toSeq
} yield LinuxPackageMapping(Seq(s -> path)).withPerms(permissions)
},
// TODO the /var/log should be generalized like defaultLinuxInstallLocation
linuxPackageMappings in Debian <+= (normalizedName) map {
name => packageTemplateMapping("/var/log/" + name)()
},
linuxPackageSymlinks in Debian <+= (normalizedName, defaultLinuxInstallLocation) map {
(name, install) => LinuxSymlink(install + "/" + name + "/logs", "/var/log/" + name)
},
// TODO - only make these if the upstart config exists...
debianMakePrermScript <<= (normalizedName, target in Universal) map makeDebianPrermScript,
debianMakePostinstScript <<= (normalizedName, target in Universal, serverLoading in Debian) map makeDebianPostinstScript)


private def makeDebianStartScript(
replacements: Seq[(String, String)], name: String, tmpDir: File, loader: ServerLoader): Option[File] =
if (replacements.isEmpty) None
Expand All @@ -78,15 +82,13 @@ object JavaServerAppPackaging {
Some(script)
}


protected def makeDebianPrermScript(name: String, tmpDir: File): Option[File] = {
val scriptBits = JavaAppStartScript.generatePrerm(name)
val script = tmpDir / "tmp" / "bin" / "debian-prerm"
IO.write(script, scriptBits)
Some(script)
}


protected def makeDebianPostinstScript(name: String, tmpDir: File, loader: ServerLoader): Option[File] = {
val scriptBits = JavaAppStartScript.generatePostinst(name, loader)
val script = tmpDir / "tmp" / "bin" / "debian-postinst"
Expand Down

0 comments on commit 85c0b23

Please sign in to comment.