Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
Add browsermob-proxy in run supervisor (#362)
Browse files Browse the repository at this point in the history
* Add browsermob-proxy in run supervisor

* Delete browsermob proxy jar file and replaced by http get
  • Loading branch information
jlamaille authored and elgalu committed Dec 10, 2019
1 parent 363c7d3 commit 6641723
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ temp.md
git_shortlog.stdout
.bitballoon
.idea
*.DS_Store
*.iml
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ ENV FIREFOX_VERSION="${FF_VER}" \
HOME="/home/seluser" \
VNC_STORE_PWD_FILE="/home/seluser/.vnc/passwd" \
BIN_UTILS="/usr/bin" \
LIB_UTILS="/usr/lib" \
MEM_JAVA_PERCENT=80 \
WAIT_FOREGROUND_RETRY="2s" \
WAIT_VNC_FOREGROUND_RETRY="6s" \
Expand Down Expand Up @@ -740,6 +741,7 @@ ENV FIREFOX_VERSION="${FF_VER}" \
NOVNC_PORT="${DEFAULT_NOVNC_PORT}" \
NOVNC="false" \
NOVNC_WAIT_TIMEOUT="5s" \
BROWSERMOBPROXY_START="false" \
SUPERVISOR_HTTP_PORT="${DEFAULT_SUPERVISOR_HTTP_PORT}" \
SUPERVISOR_HTTP_USERNAME="supervisorweb" \
SUPERVISOR_HTTP_PASSWORD="somehttpbasicauthpwd" \
Expand Down Expand Up @@ -799,6 +801,7 @@ ENV FIREFOX_VERSION="${FF_VER}" \
VNC_STOP_SIGNAL="TERM" \
NOVNC_STOP_SIGNAL="TERM" \
VIDEO_REC_STOP_SIGNAL="INT" \
BROWSERMOBPROXY_STOP_SIGNAL="TERM" \
DOCKER_SOCK="/var/run/docker.sock" \
TEST_SLEEPS="0.1" \
ZALENIUM="false" \
Expand Down Expand Up @@ -848,6 +851,21 @@ ENV SUPERVISOR_PIDFILE="${RUN_DIR}/supervisord.pid" \
VNC_TRYOUT_ERR_LOG="${LOGS_DIR}/vnc-tryouts-stderr" \
VNC_TRYOUT_OUT_LOG="${LOGS_DIR}/vnc-tryouts-stdout"

# Include Lib Browsermob Proxy
USER root

ENV BROWSERMOBPROXY_VER=2.1.4
ENV BROWSERMOBPROXY_FOLDER=browsermob-proxy-${BROWSERMOBPROXY_VER}

RUN wget -nv -O browsermob-proxy.zip \
"https://github.com/lightbody/browsermob-proxy/releases/download/browsermob-proxy-${BROWSERMOBPROXY_VER}/browsermob-proxy-${BROWSERMOBPROXY_VER}-bin.zip" \
&& unzip -x browsermob-proxy.zip \
&& rm browsermob-proxy.zip \
&& mv ${BROWSERMOBPROXY_FOLDER}/lib/browsermob-dist-${BROWSERMOBPROXY_VER}.jar ${LIB_UTILS}/ \
&& rm -r ${BROWSERMOBPROXY_FOLDER}

USER seluser

#===================================
# Fix dirs (again) and final chores
#===================================
Expand Down
30 changes: 30 additions & 0 deletions browsermobproxy/bin/browsermob-proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

BASEDIR=`dirname $0`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`

# if user has not explicitly set a command to use to invoke java, use 'java' and assume it is on the path
if [ -z "$JAVACMD" ]
then
JAVACMD="java"
fi

"$JAVACMD" $JAVA_OPTS \
-Dapp.name="browsermob-proxy" \
-Dbasedir="$BASEDIR" \
-jar "$BASEDIR/lib/browsermob-dist-2.1.4.jar" \
--port ${ENV_BROWSERMOBPROXY_PORT:-8080}
"$@"

# if we couldn't find java, print a helpful error message
if [ $? -eq 127 ]
then
echo
echo "Unable to run java using command: $JAVACMD"
echo "Make sure java is installed and on the path, or set JAVACMD to the java executable before running this script."
echo
echo "Example:"
echo
echo " $ JAVACMD=/var/lib/jdk/bin/java ./browsermob-proxy"
echo
fi
52 changes: 52 additions & 0 deletions browsermobproxy/etc/supervisor/conf.d/browsermobproxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[program:browsermobproxy]

;The relative priority of the program in the start and shutdown ordering.
;Lower priorities indicate programs that start first and shut down last.
priority=95

;User to run-as, note environment expansion outside of `command` is only
;supported in supervisor >= 3.2
;user=seluser

;The command that will be run when this program is started.
;Controlled programs should themselves not be daemons, as supervisord
;assumes it is responsible for daemonizing its subprocesses
directory=/home/seluser
command=%(ENV_BIN_UTILS)s/browsermob-proxy

;If true, this program will start automatically when supervisord is started.
;default=true
autostart=%(ENV_BROWSERMOBPROXY_START)s

;If false, the process will never be autorestarted.
;If true, the process will be unconditionally restarted when it exits,
;without regard to its exit code. default=unexpected
;If unexpected, the process will be restart when the program exits with an
;exit code that is not one of the exit codes associated with this process.
autorestart=unexpected

;Set to 0 to indicate that the program needn’t stay running for any
;particular amount of time.
;So using custom wait-xxxx.sh scripts to perform a more efficient
;active waiting until https://github.com/Supervisor/supervisor/issues/584
startsecs=2

;The number of serial failure attempts that supervisord will allow when
;attempting to start the program before giving up and puting the process
;into an FATAL state.
startretries=3

;Logs
redirect_stderr=false
stdout_logfile=%(ENV_LOGS_DIR)s/browsermobproxy-stdout.log
stderr_logfile=%(ENV_LOGS_DIR)s/browsermobproxy-stderr.log
stdout_logfile_maxbytes=%(ENV_LOGFILE_MAXBYTES)s
stderr_logfile_maxbytes=%(ENV_LOGFILE_MAXBYTES)s
stdout_logfile_backups=%(ENV_LOGFILE_BACKUPS)s
stderr_logfile_backups=%(ENV_LOGFILE_BACKUPS)s
stdout_capture_maxbytes=%(ENV_LOGFILE_MAXBYTES)s
stderr_capture_maxbytes=%(ENV_LOGFILE_MAXBYTES)s

;The signal used to kill the program when a stop is requested. This can be
;any of TERM, HUP, INT, QUIT, KILL, USR1, or USR2. default=TERM
stopsignal=%(ENV_BROWSERMOBPROXY_STOP_SIGNAL)s

0 comments on commit 6641723

Please sign in to comment.