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

Update PDF + fix shell based examples #32

Merged
merged 1 commit into from
Dec 4, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
/tmp/*
/tmp/pids/*
/Gemfile
/Gemfile.lock
**/.DS_Store
.envrc.local
Binary file modified README.pdf
Binary file not shown.
47 changes: 23 additions & 24 deletions example/cluster.sh
Original file line number Diff line number Diff line change
@@ -1,53 +1,44 @@
#!/usr/bin/env bash

export txtblk='\e[0;30m'
export txtred='\e[0;31m'
export txtgrn='\e[0;32m'
export txtylw='\e[0;33m'
export txtblu='\e[0;34m'
export txtpur='\e[0;35m'
export txtcyn='\e[0;36m'
export txtwht='\e[0;37m'
export clr='\e[0;0m'
source colors.sh

[[ -f cluster.sh ]] || {
echo -e "${txtred}Please run this from the ./example folder.${clr}"
exit 1
}

[[ -n ${BUNDLE_GEMFILE} || -f ../Gemfile ]] || {
echo -e "${txtred}Please choose either Puma v5 or Puma v6, by running:${clr}"
echo -e "${txtgrn}make puma-v5 or make puma-v6"
exit 2
}

if [[ -n "${BUNDLE_GEMFILE}" || -f ../Gemfile ]]; then
echo -e "${txtgrn}OK: We have either BUNDLE_GEMFILE defined or ../Gemfile"
[[ -z $BUNDLE_GEMFILE ]] && BUNDLE_GEMFILE=Gemfile
else
export BUNDLE_GEMFILE=Gemfile.puma-v6
echo -e "${txtylw}WARNING: Set BUNDLE_GEMFILE to either v5 or v6."
echo -e "${txtylw} Since none we set, we selected v6 for now."
sleep 2
fi

export GEMFILE=${BUNDLE_GEMFILE}

if [[ -n ${BUNDLE_GEMFILE} && -f "${BUNDLE_GEMFILE}" ]]; then
echo -e "${txtylw}Using GEMFILE: ${BUNDLE_GEMFILE}${clr}"
else
if [[ -z ${GEMFILE} || ! -f "${GEMFILE}" ]]; then
export GEMFILE="../${BUNDLE_GEMFILE}"
[[ -f ${GEMFILE} ]] || {
echo -e "${txtred}ERROR: File [${GEMFILE}] does not exist ${clr}"
exit 3
}
fi

echo -e "${txtylw}Using GEMFILE: ${txtgrn}[${GEMFILE}]${clr}"
echo -e "${txtylw}Installing Bundled Gems...${clr}"

(
(
cd .. || exit 2;
export BUNDLE_GEMFILE=${BUNDLE_GEMFILE:-"Gemfile"} ;
bundle check || bundle install
) >/dev/null

echo -e "${txtylw}GEMFILE in USE: ${txtgrn}${BUNDLE_GEMFILE}${clr}"
echo
echo -e "${txtblu}Ensuring your dependencies are installed...${clr}"
sleep 1


pid=$(ps -ef | grep puma | grep example | awk '{print $2}')

[[ -n $pid ]] && kill $pid && sleep 1
Expand Down Expand Up @@ -77,7 +68,15 @@ curl http://0.0.0.0:9292/ > "${output}" 2>/dev/null
exit 3
}

echo -e "${txtgrn}Puma Daemon is running and returning the expected string.${clr}"
echo -e "${txtblu}Currently Running Puma Processes:${txtcyn}"

ps auxww | grep [p]uma

echo
echo -e "${txtgrn}┌─────────────────────────────────────────────────────────────────────────┐"
echo -e "${txtgrn}│ Puma Daemon is UP in the CLUSTER/WORKERS mode & HTTP response is 200/OK │"
echo -e "${txtgrn}└─────────────────────────────────────────────────────────────────────────┘${clr}"
echo


ps -ef | grep [p]uma

11 changes: 11 additions & 0 deletions example/colors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

export txtblk='\e[0;30m'
export txtred='\e[0;31m'
export txtgrn='\e[0;32m'
export txtylw='\e[0;33m'
export txtblu='\e[0;34m'
export txtpur='\e[0;35m'
export txtcyn='\e[0;36m'
export txtwht='\e[0;37m'
export clr='\e[0;0m'

32 changes: 32 additions & 0 deletions example/kill-puma.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

source colors.sh

# Kill any process matching "puma" in the name
declare -a pids
pids=( $(ps -ef | grep [p]uma | grep -v puma: | grep -v kill-puma | grep -v grep | awk '{print $2}') )

echo -e "${txtgrn}Currently running Puma Processes:${clr}"
echo -e "${txtylw}"
ps -ef | grep [p]uma | grep -v kill-puma
echo -en "${clr}"
if [[ -z ${pids[*]} ]] ; then
echo -e "${txtred}No puma processes were found, nothing to kill.${clr}"
else
echo "Found the following pids matching Puma: [${pids[*]}]"
echo "Let the killing commence..."
for pid in "${pids[@]}"; do
[[ -n $(ps -p $pid) ]] && {
echo "killing $pid..."
kill $pid 2>/dev/null
}
done
sleep 1
for pid in "${pids[@]}"; do
[[ -n $(ps -p $pid) ]] && {
echo "nuking $pid..."
kill -9 $pid 2>/dev/null
}
done
fi

21 changes: 9 additions & 12 deletions example/single.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
#!/usr/bin/env bash

export txtblk='\e[0;30m'
export txtred='\e[0;31m'
export txtgrn='\e[0;32m'
export txtylw='\e[0;33m'
export txtblu='\e[0;34m'
export txtpur='\e[0;35m'
export txtcyn='\e[0;36m'
export txtwht='\e[0;37m'
export clr='\e[0;0m'
source colors.sh

[[ -f single.sh ]] || {
echo -e "${txtred}Please run this from the ./example folder.${clr}"
Expand All @@ -23,7 +15,7 @@ export clr='\e[0;0m'

echo -e "${txtblu}Ensuring your dependencies are installed...${clr}"

(
(
cd .. || exit 2;
bundle check || bundle install
) >/dev/null
Expand Down Expand Up @@ -55,10 +47,15 @@ curl http://0.0.0.0:9292/ > "${output}" 2>/dev/null
exit 3
}

echo -e "${txtgrn}Puma Daemon is running and returning the expected string.${clr}"
echo -e "${txtblu} Currently Running Puma Processes:$clr"

ps -ef | grep [p]uma
ps auxww | grep [p]uma

echo
echo -e "${txtgrn}┌────────────────────────────────────────────────────────────────────────┐"
echo -e "${txtgrn}│ Puma Daemon is UP in the Single Process mode & HTTP response is 200/OK │"
echo -e "${txtgrn}└────────────────────────────────────────────────────────────────────────┘${clr}"
echo



Loading