summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2018-10-25 22:29:00 +0000
committerRobert Speicher <robert@gitlab.com>2018-10-25 22:29:00 +0000
commit679c0048a8f679aad456c02e30486150bbd0d93d (patch)
tree7b8dc8313f5454bdc807dfe1201790b8318d47ef /bin
parent08d946e209c246ea9c8a8996c9629ad166e68c8b (diff)
parent1065f8ce7a261dff5a3077be46405343141733df (diff)
downloadgitlab-ce-679c0048a8f679aad456c02e30486150bbd0d93d.tar.gz
Merge branch 'an-multithreading' into 'master'
Puma in GDK and rack server lifecycle event abstractions Closes #52762 See merge request gitlab-org/gitlab-ce!22372
Diffstat (limited to 'bin')
-rwxr-xr-xbin/web5
-rwxr-xr-xbin/web_puma63
2 files changed, 68 insertions, 0 deletions
diff --git a/bin/web b/bin/web
index ecd0bbd10b0..06ff7c39296 100755
--- a/bin/web
+++ b/bin/web
@@ -3,6 +3,11 @@
cd $(dirname $0)/..
app_root=$(pwd)
+# Switch to experimental PUMA configuration
+if [ -n "${EXPERIMENTAL_PUMA}" ]; then
+ exec bin/web_puma "$@"
+fi
+
unicorn_pidfile="$app_root/tmp/pids/unicorn.pid"
unicorn_config="$app_root/config/unicorn.rb"
unicorn_cmd="bundle exec unicorn_rails -c $unicorn_config -E $RAILS_ENV"
diff --git a/bin/web_puma b/bin/web_puma
new file mode 100755
index 00000000000..178fe84800d
--- /dev/null
+++ b/bin/web_puma
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)/..
+app_root=$(pwd)
+
+puma_pidfile="$app_root/tmp/pids/puma.pid"
+puma_config="$app_root/config/puma.rb"
+
+spawn_puma()
+{
+ exec bundle exec puma --config "${puma_config}" "$@"
+}
+
+get_puma_pid()
+{
+ pid=$(cat "${puma_pidfile}")
+ if [ -z "$pid" ] ; then
+ echo "Could not find a PID in $puma_pidfile"
+ exit 1
+ fi
+ echo "${pid}"
+}
+
+start()
+{
+ spawn_puma -d
+}
+
+start_foreground()
+{
+ spawn_puma
+}
+
+stop()
+{
+ get_puma_pid
+ kill -QUIT "$(get_puma_pid)"
+}
+
+reload()
+{
+ kill -USR2 "$(get_puma_pid)"
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ start_foreground)
+ start_foreground
+ ;;
+ stop)
+ stop
+ ;;
+ reload)
+ reload
+ ;;
+ *)
+ echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}"
+ ;;
+esac