Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unify upstart and system v start scripts #138

Merged
merged 3 commits into from
Jan 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ execRunner () {
echo ""
}

exec "$@"
# We Don't use "exec" here for our pids to be accurate.
"$@"
}
addJava () {
dlog "[addJava] arg = '$1'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,21 @@ 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

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 $?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)] =
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,16 @@ 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,
description = descr,
execScript = name,
chdir = appDir,
appName = name,
appClasspath = appClasspath,
appMainClass = mainClass.get,
daemonUser = daemonUser)
},
// TODO - Default locations shouldn't be so hacky.
Expand Down