diff --git a/announcement.gemspec b/announcement.gemspec index 8374a62..3e693b7 100644 --- a/announcement.gemspec +++ b/announcement.gemspec @@ -37,19 +37,23 @@ if old_gemfile_text != new_gemfile_text end 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 '' + command2 = '' if old_playground != new_playground puts 'updating playground' - File.open(ENV['PWD']+'/app/controllers/admin/playground_controller.rb', 'w') do |file| - file.write new_playground - end + 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 end old_multithread = File.read (ENV['PWD']+'/app/models/multithread.rb') rescue '' new_multithread = File.read (app_path+'/temp_file/multithread.rb') rescue '' + command3 = '' if old_multithread != new_multithread puts 'updating multithread' - File.open(ENV['PWD']+'/app/models/multithread.rb', 'w') do |file| - file.write new_multithread - end + 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 end 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 @@ -64,7 +68,8 @@ if old_gemfile_text != new_gemfile_text else command1 = "cd #{ENV['PWD']} && gem install bundler -v 1.17.3 && mv -f Gemfile.lock Gemfile.lock.bak123 && bundle update" end - all_command = "#{command1} && screen -d -m -S auto_reopen 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" + 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}|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 Bundler.with_clean_env do puts ENV['PWD'] @@ -72,8 +77,9 @@ if old_gemfile_text != new_gemfile_text exec(all_command) end end - a.priority = 2 - sleep 2 + now_priority = Thread.current.priority.to_i + system('sleep 2') + a.priority = now_priority + 2 a.run #Thread.exit end