Skip to content

Commit

Permalink
[build] add MADVDONTNEED to builds (#23001) (#23175)
Browse files Browse the repository at this point in the history
* add MADVDONTNEED to builds

* delay setting godebug in init scripts

(cherry picked from commit 8a68dc9)
  • Loading branch information
fearful-symmetry authored Dec 17, 2020
1 parent 6358e72 commit cb12286
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dev-tools/packaging/templates/deb/elastic-agent.init.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ BEAT_USER="{{.BeatUser}}"
WRAPPER_ARGS="-r / -n -p $PIDFILE"
SCRIPTNAME=/etc/init.d/{{.ServiceName}}


# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/{{.ServiceName}} ] && . /etc/default/{{.ServiceName}}

DEFAULT_GODEBUG="madvdontneed=1"
export GODEBUG=${GODEBUG-$DEFAULT_GODEBUG}

[ "$BEAT_USER" != "root" ] && WRAPPER_ARGS="$WRAPPER_ARGS -u $BEAT_USER"
USER_WRAPPER="su"
USER_WRAPPER_ARGS="$BEAT_USER -c"
Expand Down
4 changes: 4 additions & 0 deletions dev-tools/packaging/templates/deb/init.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ BEAT_USER="{{.BeatUser}}"
WRAPPER_ARGS="-r / -n -p $PIDFILE"
SCRIPTNAME=/etc/init.d/{{.ServiceName}}


# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/{{.ServiceName}} ] && . /etc/default/{{.ServiceName}}

DEFAULT_GODEBUG="madvdontneed=1"
export GODEBUG=${GODEBUG-$DEFAULT_GODEBUG}

[ "$BEAT_USER" != "root" ] && WRAPPER_ARGS="$WRAPPER_ARGS -u $BEAT_USER"
USER_WRAPPER="su"
USER_WRAPPER_ARGS="$BEAT_USER -c"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ LABEL \

ENV ELASTIC_CONTAINER "true"
ENV PATH={{ $beatHome }}:$PATH
ENV GODEBUG="madvdontneed=1"

# Add an init process, check the checksum to make sure it's a match
RUN set -e ; \
Expand Down
1 change: 1 addition & 0 deletions dev-tools/packaging/templates/docker/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ LABEL \

ENV ELASTIC_CONTAINER "true"
ENV PATH={{ $beatHome }}:$PATH
ENV GODEBUG="madvdontneed=1"

# Add an init process, check the checksum to make sure it's a match
RUN set -e ; \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ After=network-online.target
User={{ .BeatUser }}
Group={{ .BeatUser }}
{{- end }}
Environment="GODEBUG='madvdontneed=1'"
Environment="BEAT_CONFIG_OPTS=-c /etc/{{.BeatName}}/{{.BeatName}}.yml"
ExecStart=/usr/bin/{{.BeatName}} run --environment systemd $BEAT_CONFIG_OPTS
Restart=always
Expand Down
1 change: 1 addition & 0 deletions dev-tools/packaging/templates/linux/systemd.unit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ After=network-online.target
User={{ .BeatUser }}
Group={{ .BeatUser }}
{{- end }}
Environment="GODEBUG='madvdontneed=1'"
Environment="BEAT_LOG_OPTS="
Environment="BEAT_CONFIG_OPTS=-c /etc/{{.BeatName}}/{{.BeatName}}.yml"
Environment="BEAT_PATH_OPTS=--path.home /usr/share/{{.BeatName}} --path.config /etc/{{.BeatName}} --path.data /var/lib/{{.BeatName}} --path.logs /var/log/{{.BeatName}}"
Expand Down
2 changes: 2 additions & 0 deletions dev-tools/packaging/templates/rpm/elastic-agent.init.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ wrapperopts="-r / -n -p $pidfile"
user_wrapper="su"
user_wrapperopts="$beat_user -c"
RETVAL=0
DEFAULT_GODEBUG="madvdontneed=1"
export GODEBUG=${GODEBUG-$DEFAULT_GODEBUG}

# Source function library.
. /etc/rc.d/init.d/functions
Expand Down
2 changes: 2 additions & 0 deletions dev-tools/packaging/templates/rpm/init.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ wrapperopts="-r / -n -p $pidfile"
user_wrapper="su"
user_wrapperopts="$beat_user -c"
RETVAL=0
DEFAULT_GODEBUG="madvdontneed=1"
export GODEBUG=${GODEBUG-$DEFAULT_GODEBUG}

# Source function library.
. /etc/rc.d/init.d/functions
Expand Down

0 comments on commit cb12286

Please sign in to comment.