Merge pull request #112 from overleaf/spd-gprof

Add Google debug and profiling agents to Git Bridge
This commit is contained in:
Simon Detheridge 2021-06-23 15:27:56 +01:00 committed by GitHub
commit cf7d7878a1
2 changed files with 19 additions and 0 deletions

View file

@ -28,6 +28,16 @@ FROM openjdk:11-jre
RUN apt-get update && apt-get install -y git sqlite3 procps htop net-tools sockstat \
&& rm -rf /var/lib/apt/lists
# Install Google Cloud Profiler agent
RUN mkdir -p /opt/cprof && \
wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \
| tar xzv -C /opt/cprof
# Install Google Cloud Debugger agent
RUN mkdir /opt/cdbg && \
wget -qO- https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/cdbg_java_agent_gce.tar.gz | \
tar xvz -C /opt/cdbg
RUN useradd --create-home node
COPY --from=builder /git-bridge.jar /

View file

@ -1,8 +1,17 @@
#!/bin/bash
/opt/envsubst < /envsubst_template.json > /conf/runtime.json
if [ "x$GIT_BRIDGE_JVM_ARGS" == "x" ]; then
GIT_BRIDGE_JVM_ARGS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=50.0"
fi
if [ "$ENABLE_PROFILE_AGENT" == "true" ]; then
GIT_BRIDGE_JVM_ARGS="-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=git-bridge,-cprof_service_version=1.0.0,-cprof_enable_heap_sampling=true ${GIT_BRIDGE_JVM_ARGS}"
fi
if [ "$ENABLE_DEBUG_AGENT" == "true" ]; then
GIT_BRIDGE_JVM_ARGS="-agentpath:/opt/cdbg/cdbg_java_agent.so -Dcom.google.cdbg.module=git-bridge -Dcom.google.cdbg.version=$(date +%y%m%d%H%M%S) ${GIT_BRIDGE_JVM_ARGS}"
fi
exec java $GIT_BRIDGE_JVM_ARGS -jar /git-bridge.jar /conf/runtime.json