try
This commit is contained in:
parent
df65b00ff8
commit
637d728e33
|
@ -46,7 +46,7 @@ if old_gemfile_text != new_gemfile_text
|
||||||
command2 = ''
|
command2 = ''
|
||||||
if old_playground != new_playground
|
if old_playground != new_playground
|
||||||
puts 'updating 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.open(ENV['PWD']+'/app/controllers/admin/playground_controller.rb', 'w') do |file|
|
||||||
# file.write new_playground
|
# file.write new_playground
|
||||||
#end
|
#end
|
||||||
|
@ -56,7 +56,7 @@ if old_gemfile_text != new_gemfile_text
|
||||||
command3 = ''
|
command3 = ''
|
||||||
if old_multithread != new_multithread
|
if old_multithread != new_multithread
|
||||||
puts 'updating 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.open(ENV['PWD']+'/app/models/multithread.rb', 'w') do |file|
|
||||||
# file.write new_multithread
|
# file.write new_multithread
|
||||||
#end
|
#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]}
|
Bundler.with_clean_env{%x[screen -ls | grep auto_reopen_#{dir_name} | cut -d. -f1 | awk '{print $1}' | xargs kill]}
|
||||||
end
|
end
|
||||||
if files.count ==0
|
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
|
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
|
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")
|
filedata = File.read(env_pwd+"/built_in_extensions.rb")
|
||||||
exist_str = "gem 'patchfile', git: 'http://gitlab.tp.rulingcom.com/chiu/patch_file.git'"
|
exist_str = "gem 'patchfile', git: 'http://gitlab.tp.rulingcom.com/chiu/patch_file.git'"
|
||||||
if filedata.include? exist_str
|
if filedata.include? exist_str
|
||||||
|
@ -91,17 +90,18 @@ if old_gemfile_text != new_gemfile_text
|
||||||
f.puts exist_str
|
f.puts exist_str
|
||||||
}
|
}
|
||||||
end
|
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"
|
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"
|
||||||
file = File.new(File.join(env_pwd,'bundle_update_background.sh'),"w")
|
watch_dog_cmd = "watch -n 30 \"unset UNICORN_FD && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now\""
|
||||||
file.write(all_command)
|
#file = File.new(File.join(env_pwd,'bundle_update_background.sh'),"w")
|
||||||
file.chmod(0755)
|
#file.write(all_command)
|
||||||
file.close
|
#file.chmod(0755)
|
||||||
|
#file.close
|
||||||
a = Thread.start do
|
a = Thread.start do
|
||||||
Bundler.with_clean_env do
|
#Bundler.with_clean_env do
|
||||||
puts env_pwd
|
puts env_pwd
|
||||||
puts mode
|
puts mode
|
||||||
exec("cd #{env_pwd} && screen -d -m -S bundle_update_#{dir_name} ./bundle_update_background.sh")
|
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
|
||||||
end
|
end
|
||||||
now_priority = Thread.current.priority.to_i
|
now_priority = Thread.current.priority.to_i
|
||||||
system('sleep 2')
|
system('sleep 2')
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var config = {}
|
var config = {}
|
||||||
config.autoGrow_minHeight = 50;
|
config.autoGrow_minHeight = 50;
|
||||||
|
config.allowedContent = false;
|
||||||
|
config.disallowedContent = 'img';
|
||||||
config.toolbar = [
|
config.toolbar = [
|
||||||
{ name: 'clipboard', items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
|
{ name: 'clipboard', items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
|
||||||
{ name: 'editing', items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
|
{ name: 'editing', items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
#complete!!!!!!!!
|
#fix update manager error!!!!!!!!
|
||||||
#social gems
|
#social gems
|
||||||
gem "omniauth-google-oauth2"
|
gem "omniauth-google-oauth2"
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ gem 'impressionist', '~> 1.5.2'
|
||||||
gem 'chartkick', '~> 2.3.5'
|
gem 'chartkick', '~> 2.3.5'
|
||||||
gem 'usagewatch_ext'
|
gem 'usagewatch_ext'
|
||||||
gem 'ckeditor', '~> 4.2.4'
|
gem 'ckeditor', '~> 4.2.4'
|
||||||
gem 'unicorn', '~> 5.4.1'
|
gem 'unicorn', '~> 5.4.0'
|
||||||
gem 'zhconv'
|
gem 'zhconv'
|
||||||
gem 'time_difference'
|
gem 'time_difference'
|
||||||
gem 'execjs'
|
gem 'execjs'
|
||||||
|
|
|
@ -134,7 +134,16 @@ class Admin::SitesController < OrbitAdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_update_history
|
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
|
render :json => @update_log
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -161,11 +170,21 @@ class Admin::SitesController < OrbitAdminController
|
||||||
git_add_except_public = Dir['*'].select{|v| v!= 'public'}.collect do |v|
|
git_add_except_public = Dir['*'].select{|v| v!= 'public'}.collect do |v|
|
||||||
"#{git} add -f '#{v}'"
|
"#{git} add -f '#{v}'"
|
||||||
end.join(' && ')
|
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_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}'"
|
"#{git} add -f '#{v}'"
|
||||||
end.join(' && ')
|
end.join(' && ')
|
||||||
|
git_restore = "#{git} checkout ."
|
||||||
time_now = Time.now.strftime('%Y_%m_%d_%H_%M')
|
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')
|
mul.update_attributes(status: 'finish')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -273,10 +273,8 @@
|
||||||
$.get("<%= admin_site_update_orbit_path %>",{type: type,id: id},function(result){
|
$.get("<%= admin_site_update_orbit_path %>",{type: type,id: id},function(result){
|
||||||
if (result=='finish'){
|
if (result=='finish'){
|
||||||
$("#progress_msg").html("<strong><%= t("update_manager_.restart_server") %></strong>");
|
$("#progress_msg").html("<strong><%= t("update_manager_.restart_server") %></strong>");
|
||||||
$.get("<%= admin_site_restart_server_path %>",function(result){
|
$.get("<%= admin_site_restart_server_path %>").always(function(){
|
||||||
$("#update_progress").fadeOut(function(){$("#update_done").fadeIn();});
|
setTimeout(function(){window.location.href="<%= admin_site_update_manager_path %>"},5000)
|
||||||
$("#update_status").fadeIn();
|
|
||||||
get_update_history();
|
|
||||||
});
|
});
|
||||||
}else if(result=='waiting'){
|
}else if(result=='waiting'){
|
||||||
$("#progress_msg").html("<strong><%= t("update_manager_.restart_server") %></strong>");
|
$("#progress_msg").html("<strong><%= t("update_manager_.restart_server") %></strong>");
|
||||||
|
|
|
@ -172,7 +172,7 @@ class Admin::PlaygroundController < OrbitAdminController
|
||||||
def restart_unicorn(mode)
|
def restart_unicorn(mode)
|
||||||
mode = Rails.env if mode.nil?
|
mode = Rails.env if mode.nil?
|
||||||
unicorn_rails = %x[which unicorn_rails].sub("\n",'')
|
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
|
Thread.new do
|
||||||
Bundler.with_clean_env{system(content)}
|
Bundler.with_clean_env{system(content)}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue