From 4e63c7511224e3310304de21de4c63f1c1a83551 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 23 Jan 2014 08:09:17 -0500 Subject: [PATCH 1/2] REmove `exec` from bash script. Fixes #99 --- .../com/typesafe/sbt/packager/archetypes/bash-template | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/bash-template b/src/main/resources/com/typesafe/sbt/packager/archetypes/bash-template index 8975fc243..a4065af04 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/bash-template +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/bash-template @@ -127,7 +127,8 @@ execRunner () { echo "" } - exec "$@" + # We Don't use "exec" here for our pids to be accurate. + "$@" } addJava () { dlog "[addJava] arg = '$1'" From 0e39b3a02a1afb3da26f5e8df3a9a913b5f00bcc Mon Sep 17 00:00:00 2001 From: Alexey Kardapoltsev Date: Fri, 24 Jan 2014 14:35:49 +0600 Subject: [PATCH 2/2] systemV start script refactored with new bash script --- .../sbt/packager/archetypes/systemv/start-template | 14 ++------------ .../packager/archetypes/JavaAppUpstartScript.scala | 4 ---- .../archetypes/JavaServerApplication.scala | 7 ++----- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-template b/src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-template index 3b9c662d3..6ee43a2cd 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-template +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-template @@ -13,13 +13,6 @@ test -e /etc/default/${{app_name}} && source /etc/default/${{app_name}} source /lib/init/vars.sh source /lib/lsb/init-functions -get_java_cmd() { - if [ -x "$JAVA_HOME/bin/java" ]; then - echo "$JAVA_HOME/bin/java" - else - echo $(which java) - fi -} PIDFILE=/var/run/${{app_name}}.pid @@ -27,17 +20,14 @@ if [ -z "$DAEMON_USER" ]; then DAEMON_USER=${{daemon_user}} fi -if [ -z "$JAVA_CMD" ]; then - JAVA_CMD=$(get_java_cmd) -fi # smb could define some additional options in $RUN_OPTS -RUN_CMD="-cp ${{app_classpath}} ${{app_main_class}} $RUN_OPTS" +RUN_CMD="${{chdir}}/bin/${{app_name}}" start_daemon() { log_daemon_msg "Starting" "${{app_name}}" - start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --exec "$JAVA_CMD" --start -- $RUN_CMD + start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --exec "$RUN_CMD" --start -- $RUN_OPTS log_end_msg $? } diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppUpstartScript.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppUpstartScript.scala index a4475de19..d5602ace5 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppUpstartScript.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaAppUpstartScript.scala @@ -88,8 +88,6 @@ object JavaAppStartScript { execScript: String, chdir: String, appName: String, - appMainClass: String, - appClasspath: String, daemonUser: String, retries: Int = 0, retryTimeout: Int = 60): Seq[(String, String)] = @@ -101,8 +99,6 @@ object JavaAppStartScript { "retries" -> retries.toString, "retryTimeout" -> retryTimeout.toString, "app_name" -> appName, - "app_main_class" -> appMainClass, - "app_classpath" -> appClasspath, "daemon_user" -> daemonUser) } diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala index 6ebf4e822..0382ff057 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala @@ -33,10 +33,9 @@ object JavaServerAppPackaging { // This one is begging for sbt 0.13 syntax... debianScriptReplacements <<= ( maintainer in Debian, packageSummary in Debian, serverLoading in Debian, daemonUser in Debian, normalizedName, - sbt.Keys.version, defaultLinuxInstallLocation, mainClass in Compile, scriptClasspath) - map { (author, descr, loader, daemonUser, name, version, installLocation, mainClass, cp) => + sbt.Keys.version, defaultLinuxInstallLocation) + map { (author, descr, loader, daemonUser, name, version, installLocation) => val appDir = installLocation + "/" + name - val appClasspath = cp.map(appDir + "/lib/" + _).mkString(":") JavaAppStartScript.makeReplacements( author = author, @@ -44,8 +43,6 @@ object JavaServerAppPackaging { execScript = name, chdir = appDir, appName = name, - appClasspath = appClasspath, - appMainClass = mainClass.get, daemonUser = daemonUser) }, // TODO - Default locations shouldn't be so hacky.