A platform for community discussion. Free, open, simple.
DEV: Make changes for docker_manager Pitchfork compatibility (#36456)
Loïc Guitautd3e9b019c15a
diff --git a/config/initializers/004-message_bus.rb b/config/initializers/004-message_bus.rbindex 01796551474..3ac1fdef585 100644--- a/config/initializers/004-message_bus.rb+++ b/config/initializers/004-message_bus.rb@@ -17,7 +17,8 @@ enddef setup_message_bus_env(env)return if env["__mb"]- if queue_time = env[Middleware::ProcessingRequest::REQUEST_QUEUE_SECONDS_ENV_KEY]+ if (queue_time = env[Middleware::ProcessingRequest::REQUEST_QUEUE_SECONDS_ENV_KEY]) &&+ Discourse.redis.get("docker_manager:upgrade:server_restarting").blank?if queue_time > (GlobalSetting.reject_message_bus_queue_seconds).to_fraise RateLimiter::LimitExceeded, 30 + (rand * 120).to_ienddiff --git a/config/pitchfork.conf.rb b/config/pitchfork.conf.rbindex 7c802350af1..d8e7b2033c6 100644--- a/config/pitchfork.conf.rb+++ b/config/pitchfork.conf.rb@@ -20,7 +20,7 @@ endworker_processes (ENV["UNICORN_WORKERS"] || 3).to_i# stree-ignore-listen ENV["UNICORN_LISTENER"] || "#{(ENV["UNICORN_BIND_ALL"] ? "" : "127.0.0.1:")}#{(ENV["UNICORN_PORT"] || 3000).to_i}"+listen ENV["UNICORN_LISTENER"] || "#{(ENV["UNICORN_BIND_ALL"] ? "" : "127.0.0.1:")}#{(ENV["UNICORN_PORT"] || 3000).to_i}", reuseport: trueif ENV["RAILS_ENV"] == "production"# nuke workers after 30 seconds instead of 20 seconds (the default)diff --git a/config/unicorn_launcher b/config/unicorn_launcherindex 942a9a91e14..5a4363fc99e 100755--- a/config/unicorn_launcher+++ b/config/unicorn_launcher@@ -5,30 +5,25 @@LOCAL_WEB="http://127.0.0.1:3000/"-function log()-{+function log() {echo "($$) $1"}-function on_exit()-{+function on_exit() {kill $UNICORN_PIDlog "exiting"}-function on_reload()-{- log "Stopping Sidekiq"- kill -s TSTP $UNICORN_PID+function on_reload_unicorn() {log "Reloading unicorn ($UNICORN_PID)"kill -s USR2 $UNICORN_PIDunset NEW_UNICORN_PIDcount=0while [ "$count" -lt 180 -a -z "$NEW_UNICORN_PID" ]; do- NEW_UNICORN_PID=`ps -f --ppid $UNICORN_PID | grep 'unicorn master' | grep -v old | grep -v worker | awk '{ print $2 }'`+ NEW_UNICORN_PID=$(pgrep -f -P $UNICORN_PID "unicorn master")log "Waiting for new unicorn master pid... $NEW_UNICORN_PID"- count=$((count+1))+ count=$((count + 1))sleep 1done@@ -36,11 +31,11 @@ function on_reload()count=0while [ "$count" -lt 180 -a -z "$(ps -f --ppid $NEW_UNICORN_PID | grep worker | head -1 | awk '{ print $2 }')" ]; dolog "Waiting for new unicorn workers under $NEW_UNICORN_PID to start up..."- count=$((count+1))+ count=$((count + 1))sleep 1done- curl $LOCAL_WEB &> /dev/null+ curl $LOCAL_WEB &>/dev/nullkill -s QUIT $UNICORN_PIDlog "Old pid is: $UNICORN_PID New pid is: $NEW_UNICORN_PID"UNICORN_PID=$NEW_UNICORN_PID@@ -50,33 +45,51 @@ function on_reload()fi}-function on_reopenlogs()-{+function on_reload_pitchfork() {+ log "Reloading pitchfork ($UNICORN_PID)"+ OLD_PID=$UNICORN_PID+ pitchfork "${PITCHFORK_ARGS[@]}" &+ UNICORN_PID=$!+ log "Old pid is: $OLD_PID New pid is: $UNICORN_PID"+ count=0+ while [ "$count" -lt 180 -a -z "$(pgrep -f -P $UNICORN_PID worker)" ]; do+ log "Waiting for new pitchfork workers under $UNICORN_PID to start up..."+ count=$((count + 1))+ sleep 1+ done++ kill $OLD_PID 2>/dev/null+}++function on_reopenlogs() {log "Reopening logs"kill -s USR1 $UNICORN_PID}export UNICORN_SUPERVISOR_PID=$$+if [[ -n "$RUN_PITCHFORK" ]]; then+ PITCHFORK_ARGS=()+ for arg in "$@"; do+ PITCHFORK_ARGS+=("${arg/unicorn.conf.rb/pitchfork.conf.rb}")+ done+fi+trap on_exit EXITif [[ -z "$RUN_PITCHFORK" ]]; then- trap on_reload USR2 HUP+ trap on_reload_unicorn USR2 HUPtrap on_reopenlogs USR1- unicorn $@ &+ unicorn "$@" &else- args=()- for arg in "$@"; do- args+=("${arg/unicorn.conf.rb/pitchfork.conf.rb}")- done- pitchfork "${args[@]}" &+ trap on_reload_pitchfork USR2 HUP+ pitchfork "${PITCHFORK_ARGS[@]}" &fiUNICORN_PID=$!echo "supervisor pid: $UNICORN_SUPERVISOR_PID unicorn pid: $UNICORN_PID"-while kill -0 $UNICORN_PID-do+while kill -0 $UNICORN_PID; dosleep 1done