fix crash problem in development mode
This commit is contained in:
parent
215b1c1647
commit
b8972a0ef9
|
@ -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
|
||||||
|
@ -64,7 +68,8 @@ if old_gemfile_text != new_gemfile_text
|
||||||
else
|
else
|
||||||
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
|
||||||
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
|
a = Thread.start do
|
||||||
Bundler.with_clean_env do
|
Bundler.with_clean_env do
|
||||||
puts ENV['PWD']
|
puts ENV['PWD']
|
||||||
|
@ -72,8 +77,9 @@ if old_gemfile_text != new_gemfile_text
|
||||||
exec(all_command)
|
exec(all_command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
a.priority = 2
|
now_priority = Thread.current.priority.to_i
|
||||||
sleep 2
|
system('sleep 2')
|
||||||
|
a.priority = now_priority + 2
|
||||||
a.run
|
a.run
|
||||||
#Thread.exit
|
#Thread.exit
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue