fix old site bug

This commit is contained in:
邱博亞 2021-11-27 15:07:24 +08:00
parent c2d616d95e
commit 1a6e46982c
2 changed files with 5 additions and 5 deletions

View File

@ -142,7 +142,7 @@ class Admin::PlaygroundController < OrbitAdminController
mul.save mul.save
if command == 'bundle update' if command == 'bundle update'
system('sleep 2') system('sleep 2')
Bundler.with_clean_env{system("#{RESTART_CMD}")} Bundler.with_clean_env{system("UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi")}
end end
end end
rescue => e rescue => e
@ -160,7 +160,7 @@ class Admin::PlaygroundController < OrbitAdminController
end end
def restart_server def restart_server
cmd ="#{RESTART_CMD}" cmd ="UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi"
exec_other_command(cmd) exec_other_command(cmd)
end end

View File

@ -60,7 +60,7 @@ class Admin::SitesController < OrbitAdminController
response.body = {'success'=>true}.to_json response.body = {'success'=>true}.to_json
end end
data = JSON.parse(response.body) data = JSON.parse(response.body)
%x(#{RESTART_CMD}) Bundler.with_clean_env{system("UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi")}
sleep 5 sleep 5
end end
def index def index
@ -176,7 +176,7 @@ class Admin::SitesController < OrbitAdminController
end end
Thread.new do Thread.new do
sleep 1 sleep 1
%x(#{RESTART_CMD}) Bundler.with_clean_env{system("UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi")}
end end
end end
@ -257,7 +257,7 @@ class Admin::SitesController < OrbitAdminController
def bundle_install def bundle_install
Bundler.with_clean_env { system("cd #{Rails.root} && bundle update") } Bundler.with_clean_env { system("cd #{Rails.root} && bundle update") }
%x(#{RESTART_CMD}) Bundler.with_clean_env{system("UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi")}
sleep 2 sleep 2
render :nothing => true render :nothing => true
end end