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

[fix #472] /etc/default/<package-name> should be shell script setting envars #473

Merged
merged 3 commits into from
Feb 4, 2015
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 @@ -290,11 +290,6 @@ run() {
exit $exit_code
}

# Loads a configuration file full of default command line options for this script.
loadConfigFile() {
cat "$1" | sed '/^\#/d'
}

# Now check to see if it's a good enough version
# TODO - Check to see if we have a configured default java version, otherwise use 1.6
java_version_check() {
Expand Down Expand Up @@ -367,7 +362,8 @@ ${{template_declares}}
# java_cmd is overrode in process_args when -java-home is used
declare java_cmd=$(get_java_cmd)

# if configuration files exist, prepend their contents to $@ so it can be processed by this runner
[[ -f "$script_conf_file" ]] && set -- $(loadConfigFile "$script_conf_file") "$@"

# use JAVA_OPTS to prepend its contents to $@
set -- "$JAVA_OPTS" "$@"

run "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ${{daemon_user}} daemon user
# -------------------------------------------------

# Using $JAVA_OPTS envars
# Setting -Xmx and -Xms in Megabyte
# -mem 1024

Expand All @@ -31,4 +32,8 @@
# -jvm-debug <port>

# Don't run the java version check
# -no-version-check
# -no-version-check

# Example
# JAVA_OPTS=" -Dpidfile.path=/var/run/${{app_name}}/play.pid $JAVA_OPTS"
# JAVA_OPTS=" -mem 1024 -Dkey=val -jvm-debug $JAVA_OPTS"
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
source /lib/init/vars.sh
source /lib/lsb/init-functions

# if configuration files exist, source it and use JAVA_OPTS to prepend their contents to $@
[[ -f /etc/default/${{app_name}} ]] && . /etc/default/${{app_name}}
# $JAVA_OPTS used in $RUN_CMD wrapper
export JAVA_OPTS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this overwrite preexisting JAVA_OPTS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it depends how JAVA_OPTS is set in /etc/default/${{app_name}} (if set)
JAVA_OPTS='toto' will overwrite,
JAVA_OPTS="toto $JAVA_OPTS" wouldn't

BTW, JAVA_OPTS seams not set before /etc/default

then I force export because I know JAVA_OPTS is required in wrapper subprocess created by start-stop-daemon (for any other envars required by java process, exporting it in /etc/default/ would be mandatory); if not, JAVA_OPTS would be limited to init.d script process only and not propagated to subprocess.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable. So the user has to make sure that preexisting JAVA_OPTS
are taken into account.


PIDFILE=/var/run/${{app_name}}/running.pid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
# Source function library.
. /etc/rc.d/init.d/functions

# if configuration files exist, source it and use JAVA_OPTS to prepend their contents to $@
[[ -f /etc/default/${{app_name}} ]] && . /etc/default/${{app_name}}
# $JAVA_OPTS used in $RUN_CMD wrapper
export JAVA_OPTS

prog="${{exec}}"

# FIXME The pid file should be handled by the executed script
Expand Down
8 changes: 8 additions & 0 deletions src/sphinx/archetypes/java_server/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Create ``src/templates/etc-default`` with the following template
# ${{daemon_user}} daemon user
# -------------------------------------------------

# Using $JAVA_OPTS envars
# Setting -Xmx and -Xms in Megabyte
# -mem 1024

Expand All @@ -58,9 +59,16 @@ Create ``src/templates/etc-default`` with the following template
# using a reserved parameter. See #184
# -d -- -d

# Example:
# JAVA_OPTS=" -Dpidfile.path=/var/run/${{app_name}}/play.pid $JAVA_OPTS"
# JAVA_OPTS=" -mem 1024 -Dkey=val -jvm-debug $JAVA_OPTS"

The file will be installed to ``/etc/default/<normalizedName>`` and read from there
by the startscript.

*Warning: the format changed, from java option list only, to a shell script setting environment variables.
A project using previous version should adapts its configuration file.*

Environment variables
~~~~~~~~~~~~~~~~~~~~~

Expand Down