Skip to content
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
10 changes: 10 additions & 0 deletions deploy/docker/fs/opt/appsmith/record-heap-dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset
set -o noglob

location=/appsmith-stacks/heap_dumps/ad-hoc/$(date "+%Y_%m_%d_%H_%S")/heap-profile;
mkdir -p $location;
jcmd $(pgrep -f -- "-jar\sserver.jar") GC.heap_dump filename=$location/${HOSTNAME}.log
Comment on lines +8 to +10
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance error handling and directory creation checks.

While the script is functional, adding checks for directory creation and process identification can improve robustness. Consider logging actions for better traceability.

location=/appsmith-stacks/heap_dumps/ad-hoc/$(date "+%Y_%m_%d_%H_%S")/heap-profile
mkdir -p "$location" || { echo "Error: Failed to create directory $location." >&2; exit 1; }

process_id=$(pgrep -f -- "-jar\sserver.jar" || echo "")
if [ -z "$process_id" ]; then
  echo "Error: No Java process found." >&2
  exit 1
fi

jcmd $process_id GC.heap_dump filename="$location/${HOSTNAME}.log"
echo "Heap dump recorded successfully at $location."

10 changes: 10 additions & 0 deletions deploy/docker/fs/opt/appsmith/record-thread-dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset
set -o noglob

location=/appsmith-stacks/heap_dumps/ad-hoc/$(date "+%Y_%m_%d_%H_%S")/thread-profile;
mkdir -p $location;
jcmd $(pgrep -f -- "-jar\sserver.jar") Thread.print > $location/trace-${HOSTNAME}.log
Comment on lines +8 to +10
Copy link
Contributor

Choose a reason for hiding this comment

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

Improve error handling and directory creation checks.

To ensure robustness, add checks for directory creation and process identification. Logging actions can also aid in debugging and traceability.

location=/appsmith-stacks/heap_dumps/ad-hoc/$(date "+%Y_%m_%d_%H_%S")/thread-profile
mkdir -p "$location" || { echo "Error: Failed to create directory $location." >&2; exit 1; }

process_id=$(pgrep -f -- "-jar\sserver.jar" || echo "")
if [ -z "$process_id" ]; then
  echo "Error: No Java process found." >&2
  exit 1
fi

jcmd $process_id Thread.print > "$location/trace-${HOSTNAME}.log"
echo "Thread dump recorded successfully at $location."

10 changes: 10 additions & 0 deletions deploy/docker/fs/opt/appsmith/thread-profile-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset
set -o noglob

location=/appsmith-stacks/heap_dumps/ad-hoc/$(date "+%Y_%m_%d_%H_%S")/thread-profile;
mkdir -p $location;
jcmd $(pgrep -f -- "-jar\sserver.jar") JFR.start name=profile filename=$location/profile-${HOSTNAME}.jfr
8 changes: 8 additions & 0 deletions deploy/docker/fs/opt/appsmith/thread-profile-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset
set -o noglob
Comment on lines +1 to +6
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider enhancing error handling and logging.

While the script is set to fail on errors with set -o errexit, it would be beneficial to include logging for better traceability and debugging. Additionally, consider handling scenarios where pgrep might return multiple PIDs or none at all.

#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset
set -o noglob

process_id=$(pgrep -f -- "-jar\sserver.jar" || echo "")
if [ -z "$process_id" ]; then
  echo "Error: No Java process found." >&2
  exit 1
fi

jcmd $process_id JFR.dump name=profile
echo "JFR profile dumped successfully."


jcmd $(pgrep -f -- "-jar\sserver.jar") JFR.dump name=profile