diff --git a/announcement.gemspec b/announcement.gemspec index e51eb90..891f41b 100644 --- a/announcement.gemspec +++ b/announcement.gemspec @@ -46,7 +46,7 @@ if old_gemfile_text != new_gemfile_text command2 = '' if old_playground != new_playground puts 'updating playground' - command2 = "cp -f #{app_path}/temp_file/playground_controller.rb #{env_pwd}/app/controllers/admin/playground_controller.rb &&" + command2 = "cp -f #{app_path}/temp_file/playground_controller.rb #{env_pwd}/app/controllers/admin/playground_controller.rb ;" #File.open(ENV['PWD']+'/app/controllers/admin/playground_controller.rb', 'w') do |file| # file.write new_playground #end @@ -56,7 +56,7 @@ if old_gemfile_text != new_gemfile_text command3 = '' if old_multithread != new_multithread puts 'updating multithread' - command3 = "cp -f #{app_path}/temp_file/multithread.rb #{env_pwd}/app/models/multithread.rb &&" + command3 = "cp -f #{app_path}/temp_file/multithread.rb #{env_pwd}/app/models/multithread.rb ;" #File.open(ENV['PWD']+'/app/models/multithread.rb', 'w') do |file| # file.write new_multithread #end @@ -76,11 +76,10 @@ if old_gemfile_text != new_gemfile_text Bundler.with_clean_env{%x[screen -ls | grep auto_reopen_#{dir_name} | cut -d. -f1 | awk '{print $1}' | xargs kill]} end if files.count ==0 - command1 = "cd #{env_pwd} && gem install bundler -v 1.17.3 && bundle update" + command1 = "gem install bundler -v 1.17.3 ; bundle install --force ; bundle update" else - command1 = "cd #{env_pwd} && gem install bundler -v 1.17.3 && mv -f Gemfile.lock Gemfile.lock.bak123 && bundle update" + command1 = "gem install bundler -v 1.17.3 ; mv -f Gemfile.lock Gemfile.lock.bak123 ; bundle install --force ; bundle update" end - Bundler.with_clean_env{system("cd #{env_pwd} && screen -d -m -S auto_reopen_#{dir_name} watch -n 30 bundle exec --keep-file-descriptors #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now")} filedata = File.read(env_pwd+"/built_in_extensions.rb") exist_str = "gem 'patchfile', git: 'http://gitlab.tp.rulingcom.com/chiu/patch_file.git'" if filedata.include? exist_str @@ -91,17 +90,18 @@ if old_gemfile_text != new_gemfile_text f.puts exist_str } end - all_command = "#{command1} && cd #{env_pwd} && #{command2} #{command3} #{command4} && kill -s TERM `cat tmp/pids/unicorn.pid` && unset UNICORN_FD && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now" - file = File.new(File.join(env_pwd,'bundle_update_background.sh'),"w") - file.write(all_command) - file.chmod(0755) - file.close + all_command = "#{command1} ; #{command2} #{command3} #{command4} ; kill -s TERM `cat tmp/pids/unicorn.pid` ; unset UNICORN_FD ; bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now" + watch_dog_cmd = "watch -n 30 \"unset UNICORN_FD && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now\"" + #file = File.new(File.join(env_pwd,'bundle_update_background.sh'),"w") + #file.write(all_command) + #file.chmod(0755) + #file.close a = Thread.start do - Bundler.with_clean_env do + #Bundler.with_clean_env do puts env_pwd puts mode - exec("cd #{env_pwd} && screen -d -m -S bundle_update_#{dir_name} ./bundle_update_background.sh") - end + exec("cd #{env_pwd} && env -i HOME=\"$HOME\" bash -l -c \"#{all_command}\" && screen -d -m -S auto_reopen_#{dir_name} #{watch_dog_cmd} ") + #end end now_priority = Thread.current.priority.to_i system('sleep 2') diff --git a/app/assets/javascripts/form.js b/app/assets/javascripts/form.js index 941193e..6be0876 100644 --- a/app/assets/javascripts/form.js +++ b/app/assets/javascripts/form.js @@ -1,6 +1,8 @@ $(document).ready(function() { var config = {} config.autoGrow_minHeight = 50; + config.allowedContent = false; + config.disallowedContent = 'img'; config.toolbar = [ { name: 'clipboard', items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] }, { name: 'editing', items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] }, diff --git a/temp_file/Gemfile b/temp_file/Gemfile index 41e0b2a..a20381f 100644 --- a/temp_file/Gemfile +++ b/temp_file/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -#complete!!!!!!!! +#fix update manager error!!!!!!!! #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 fe99b81..bf10379 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 @@ -149,7 +158,7 @@ class Admin::SitesController < OrbitAdminController mul.update_attributes(status: 'waiting') Thread.new do ubuntu_version = %x[lsb_release -a | grep Release].scan(/\d.*\d/)[0] - git = 'git' + git = 'git' if Float(ubuntu_version) <= 14.04 && Float(%x[git --version].scan(/\d.\d/)[0]) < 1.9 if %x[uname -m].scan('64').count !=0 cmd0 = system("wget https://ruling.digital/uploads/asset/git_1.9.1-1_amd64.deb && dpkg -x git_1.9.1-1_amd64.deb ./git_1.9.1") @@ -161,11 +170,21 @@ class Admin::SitesController < OrbitAdminController git_add_except_public = Dir['*'].select{|v| v!= 'public'}.collect do |v| "#{git} add -f '#{v}'" end.join(' && ') + git_add_custom = (Dir['*'].select{|v| v!= 'Gemfile' && v !='app' && v != 'lib' && v != 'config' && v != 'public'} + ['app/templates','config/mongoid.yml']).collect do |v| + "#{git} add -f --all '#{v}'" + end.join(' && ') git_add_all_program = (Dir['app/*'].select{|v| !v.include? 'templates'} + Dir['lib/*'] + Dir['config/*'].select{|v| !v.include? 'mongoid.yml'}).collect do |v| "#{git} add -f '#{v}'" end.join(' && ') + git_restore = "#{git} checkout ." 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}")} + if %x[git config user.name].empty? + %x[git config --global user.name "rulingcom"] + end + if %x[git config user.email].empty? + %x[git config --global user.email "orbit@rulingcom.com"] + end + 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_custom} && #{git_restore} && #{git_add_except_public}&& #{git} commit -m complete_#{type}_#{time_now}")} mul.update_attributes(status: 'finish') end end 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") %>"); diff --git a/temp_file/playground_controller.rb b/temp_file/playground_controller.rb index 665e82e..851ebfa 100644 --- a/temp_file/playground_controller.rb +++ b/temp_file/playground_controller.rb @@ -172,7 +172,7 @@ class Admin::PlaygroundController < OrbitAdminController def restart_unicorn(mode) mode = Rails.env if mode.nil? unicorn_rails = %x[which unicorn_rails].sub("\n",'') - content = "kill -s TERM `cat tmp/pids/unicorn.pid` && unset UNICORN_FD && sleep 1 && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode} | at now" + content = "kill -s TERM `cat tmp/pids/unicorn.pid` && unset UNICORN_FD && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode} | at now" Thread.new do Bundler.with_clean_env{system(content)} end