This commit is contained in:
chiu 2020-02-15 10:09:44 +08:00
parent 673b7b8fee
commit 7f8be64adb
1 changed files with 11 additions and 7 deletions

View File

@ -37,19 +37,23 @@ if old_gemfile_text != new_gemfile_text
end end
old_playground = File.read (ENV['PWD']+'/app/controllers/admin/playground_controller.rb') rescue '' old_playground = File.read (ENV['PWD']+'/app/controllers/admin/playground_controller.rb') rescue ''
new_playground = File.read (app_path+'/temp_file/playground_controller.rb') rescue '' new_playground = File.read (app_path+'/temp_file/playground_controller.rb') rescue ''
command2 = ''
if old_playground != new_playground if old_playground != new_playground
puts 'updating playground' puts 'updating playground'
File.open(ENV['PWD']+'/app/controllers/admin/playground_controller.rb', 'w') do |file| command2 = "cp -f #{app_path}/temp_file/playground_controller.rb #{ENV['PWD']}/app/controllers/admin/playground_controller.rb"
file.write new_playground #File.open(ENV['PWD']+'/app/controllers/admin/playground_controller.rb', 'w') do |file|
end # file.write new_playground
#end
end end
old_multithread = File.read (ENV['PWD']+'/app/models/multithread.rb') rescue '' old_multithread = File.read (ENV['PWD']+'/app/models/multithread.rb') rescue ''
new_multithread = File.read (app_path+'/temp_file/multithread.rb') rescue '' new_multithread = File.read (app_path+'/temp_file/multithread.rb') rescue ''
command3 = ''
if old_multithread != new_multithread if old_multithread != new_multithread
puts 'updating multithread' puts 'updating multithread'
File.open(ENV['PWD']+'/app/models/multithread.rb', 'w') do |file| command3 = "cp -f #{app_path}/temp_file/multithread.rb #{ENV['PWD']}/app/models/multithread.rb"
file.write new_multithread #File.open(ENV['PWD']+'/app/models/multithread.rb', 'w') do |file|
end # file.write new_multithread
#end
end end
log_development = File.mtime(ENV['PWD']+'/log/development.log').strftime('%Y%m%d%H%M').to_i rescue 0 log_development = File.mtime(ENV['PWD']+'/log/development.log').strftime('%Y%m%d%H%M').to_i rescue 0
log_production = File.mtime(ENV['PWD']+'/log/production.log').strftime('%Y%m%d%H%M').to_i rescue 0 log_production = File.mtime(ENV['PWD']+'/log/production.log').strftime('%Y%m%d%H%M').to_i rescue 0
@ -65,7 +69,7 @@ if old_gemfile_text != new_gemfile_text
command1 = "cd #{ENV['PWD']} && gem install bundler -v 1.17.3 && mv -f Gemfile.lock Gemfile.lock.bak123 && bundle update" command1 = "cd #{ENV['PWD']} && gem install bundler -v 1.17.3 && mv -f Gemfile.lock Gemfile.lock.bak123 && bundle update"
end end
dir_name = ENV['PWD'].split('/')[-1] dir_name = ENV['PWD'].split('/')[-1]
all_command = "#{command1} && cd #{ENV['PWD']} && screen -d -m -S auto_reopen_#{dir_name} watch -n 30 bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode} && kill -s TERM `cat tmp/pids/unicorn.pid` && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now" all_command = "#{command1} && cd #{ENV['PWD']} && screen -d -m -S auto_reopen_#{dir_name} watch -n 30 bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now ; #{command2} ; #{command3} ; kill -s TERM `cat tmp/pids/unicorn.pid` ; bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}|at now"
a = Thread.start do a = Thread.start do
Bundler.with_clean_env do Bundler.with_clean_env do
puts ENV['PWD'] puts ENV['PWD']