From ae2735fb5f3a933fd249e91b5a307bc48dc1220e Mon Sep 17 00:00:00 2001 From: chiu Date: Thu, 20 Feb 2020 16:18:43 +0800 Subject: [PATCH] fix some error --- temp_file/Gemfile | 4 ++-- .../app/controllers/admin/sites_controller.rb | 15 ++++++++++++--- .../app/views/admin/sites/update_manager.erb | 6 ++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/temp_file/Gemfile b/temp_file/Gemfile index 41e0b2a..3839915 100644 --- a/temp_file/Gemfile +++ b/temp_file/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -#complete!!!!!!!! +#complete2!!!!!!!! #social gems gem "omniauth-google-oauth2" @@ -51,7 +51,7 @@ gem 'impressionist', '~> 1.5.2' gem 'chartkick', '~> 2.3.5' gem 'usagewatch_ext' gem 'ckeditor', '~> 4.2.4' -gem 'unicorn', '~> 5.4.1' +gem 'unicorn', '~> 5.4.0' gem 'zhconv' gem 'time_difference' gem 'execjs' diff --git a/temp_file/app/controllers/admin/sites_controller.rb b/temp_file/app/controllers/admin/sites_controller.rb index cd0b47e..bc26937 100644 --- a/temp_file/app/controllers/admin/sites_controller.rb +++ b/temp_file/app/controllers/admin/sites_controller.rb @@ -134,7 +134,16 @@ class Admin::SitesController < OrbitAdminController end def get_update_history - @update_log = %x{git log --pretty=format:"%H','%ad','%s" --date=short}.split("\n").map{|log| log.gsub("'","").split(",")}.to_json + update_log = %x{git log --pretty=format:"%H','%ad','%s" --date=short}.split("\n") + emergency_log = %x{git reflog --pretty=format:"%H','%ad','%s" --date=short}.split("\n") + @update_log = update_log.collect do |v| + if v.include? 'complete_update_' + tmp = emergency_log.select{|v1| v1.exclude?('complete_update_') && v1.include?(v.split(/complete_update_/)[-1])}[0] rescue [] + [v,tmp] + else + v + end + end.flatten.map{|log| log.gsub("'","").split(",")}.to_json render :json => @update_log end @@ -165,7 +174,7 @@ class Admin::SitesController < OrbitAdminController "#{git} add -f '#{v}'" end.join(' && ') time_now = Time.now.strftime('%Y_%m_%d_%H_%M') - Bundler.with_clean_env{system("#{git_add_except_public} && #{git} commit -m auto_backup_before_#{type}_#{time_now} && #{git} reset #{commit} --mixed && #{git_add_all_program} && #{git} reset #{commit} --merge && #{git} commit -m complete_#{type}_#{time_now}")} + Bundler.with_clean_env{system("#{git_add_except_public} && #{git} commit -m auto_backup_before_#{type}_#{time_now} && #{git} reset #{commit} --mixed && #{git_add_all_program} && #{git} reset #{commit} --merge && #{git_add_except_public}&& #{git} commit -m complete_#{type}_#{time_now}")} mul.update_attributes(status: 'finish') end end @@ -196,8 +205,8 @@ class Admin::SitesController < OrbitAdminController def restart_server mode = Rails.env unicorn_rails = %x[which unicorn_rails].sub("\n",'') - Bundler.with_clean_env{system("kill -s TERM `cat tmp/pids/unicorn.pid` && unset UNICORN_FD && sleep 1 && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}")} render :nothing => true + Bundler.with_clean_env{system("kill -s TERM `cat tmp/pids/unicorn.pid` && unset UNICORN_FD && sleep 1 && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}")} end private diff --git a/temp_file/app/views/admin/sites/update_manager.erb b/temp_file/app/views/admin/sites/update_manager.erb index cbbb90b..d0a0eae 100644 --- a/temp_file/app/views/admin/sites/update_manager.erb +++ b/temp_file/app/views/admin/sites/update_manager.erb @@ -273,10 +273,8 @@ $.get("<%= admin_site_update_orbit_path %>",{type: type,id: id},function(result){ if (result=='finish'){ $("#progress_msg").html("<%= t("update_manager_.restart_server") %>"); - $.get("<%= admin_site_restart_server_path %>",function(result){ - $("#update_progress").fadeOut(function(){$("#update_done").fadeIn();}); - $("#update_status").fadeIn(); - get_update_history(); + $.get("<%= admin_site_restart_server_path %>").always(function(){ + setTimeout(function(){window.location.href="<%= admin_site_update_manager_path %>"},5000) }); }else if(result=='waiting'){ $("#progress_msg").html("<%= t("update_manager_.restart_server") %>");