fix some error

This commit is contained in:
chiu 2021-01-28 11:19:11 +08:00
parent fdac822036
commit 0f0c4aae48
3 changed files with 18 additions and 17 deletions

View File

@ -70,9 +70,11 @@ class Admin::RegisteredSitesController < OrbitAdminController
end end
if urls.nil? if urls.nil?
tp1.status = 'domain is blank' tp1.status = 'domain is blank'
tp1.can_login = false
elsif urls == [nil,nil] elsif urls == [nil,nil]
tp1.status = 'domain not found' tp1.status = 'domain not found'
tp1.href = 'http://'+site.site_domain tp1.href = 'http://'+site.site_domain
tp1.can_login = false
elsif !urls[0].to_s.empty? || !urls[1].to_s.empty? elsif !urls[0].to_s.empty? || !urls[1].to_s.empty?
tp1.status = 'ok' tp1.status = 'ok'
if !urls[0].empty? if !urls[0].empty?
@ -82,7 +84,7 @@ class Admin::RegisteredSitesController < OrbitAdminController
end end
tp1.href = root_url tp1.href = root_url
uri = URI(root_url) uri = URI(root_url)
Net::HTTP.start(uri.host, uri.port,:use_ssl => uri.scheme == 'https',open_timeout: 30,read_timeout: 30) do |http| Net::HTTP.start(uri.host, uri.port,:use_ssl => uri.scheme == 'https',open_timeout: 30,read_timeout: 30,verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
r3 = login_reomote(http,root_url) r3 = login_reomote(http,root_url)
if r3.code != '200' if r3.code != '200'
tp1.can_login = true tp1.can_login = true
@ -125,6 +127,7 @@ class Admin::RegisteredSitesController < OrbitAdminController
else else
tp1.href = 'http://'+site.site_domain tp1.href = 'http://'+site.site_domain
tp1.status = 'bad gateway' tp1.status = 'bad gateway'
tp1.can_login = false
end end
tp1.save! tp1.save!
end end
@ -218,7 +221,7 @@ class Admin::RegisteredSitesController < OrbitAdminController
uri = URI(root_url) uri = URI(root_url)
puts 'starting' puts 'starting'
begin begin
Net::HTTP.start(uri.host, uri.port,:use_ssl => uri.scheme == 'https',open_timeout: 30,read_timeout: 30) do |http| Net::HTTP.start(uri.host, uri.port,:use_ssl => uri.scheme == 'https',open_timeout: 30,read_timeout: 30,verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
r3 = login_reomote(http,root_url) r3 = login_reomote(http,root_url)
r4 = get_website(uri,http,r3) r4 = get_website(uri,http,r3)
uri2 = URI ("#{root_url}/admin/playground") uri2 = URI ("#{root_url}/admin/playground")
@ -226,10 +229,8 @@ class Admin::RegisteredSitesController < OrbitAdminController
if r5.code.to_s != '200' if r5.code.to_s != '200'
not_login_flag = true not_login_flag = true
end end
puts '1'
if !not_login_flag if !not_login_flag
not_accept_flag = true not_accept_flag = true
puts '2'
uri3 = URI ("#{root_url}/admin/playground/command") uri3 = URI ("#{root_url}/admin/playground/command")
doc = Nokogiri::HTML(r5.body) rescue nil doc = Nokogiri::HTML(r5.body) rescue nil
csrf_data = doc.search("meta[name='csrf-token']")[0].attributes['content'].value rescue nil csrf_data = doc.search("meta[name='csrf-token']")[0].attributes['content'].value rescue nil
@ -237,7 +238,6 @@ class Admin::RegisteredSitesController < OrbitAdminController
count = 0 count = 0
flag = false flag = false
res = JSON.parse(r6.body) rescue '' res = JSON.parse(r6.body) rescue ''
puts ['3',res.inspect]
if (res == {"success"=>true} || r6.code.to_s != '200') if (res == {"success"=>true} || r6.code.to_s != '200')
not_accept_flag = false not_accept_flag = false
last_length = 0 last_length = 0
@ -320,29 +320,24 @@ class Admin::RegisteredSitesController < OrbitAdminController
#log.save! #log.save!
end end
rescue => e rescue => e
not_accept_flag = true timeout_flag = true
puts e puts e
end end
puts 'out'
if not_accept_flag || not_login_flag if not_accept_flag || not_login_flag
log.status = 'failed' log.status = 'failed'
log.last_message = "can't login to admin" log.last_message = "can't login to admin"
elsif !timeout_flag elsif !timeout_flag
system('sleep 5')
if sel_flag || site.is_alive? if sel_flag || site.is_alive?
puts 'finish2'
log.status = 'finish' log.status = 'finish'
else else
log.status = 'failed' log.status = 'failed'
end end
else else
puts 'timeout_flag'
system('sleep 10') system('sleep 10')
puts 'sleep finish'
if site.is_alive? if site.is_alive?
puts 'finish'
log.status = 'finish' log.status = 'finish'
else else
puts 'failed'
log.status = 'failed' log.status = 'failed'
#update_flags = UpdateFlags.first #update_flags = UpdateFlags.first
#update_flags.bundle_update_flag = false #update_flags.bundle_update_flag = false
@ -393,6 +388,7 @@ class Admin::RegisteredSitesController < OrbitAdminController
site = RegisteredSite.find(site_id) rescue nil site = RegisteredSite.find(site_id) rescue nil
if !site.nil? && (site.site_statuses.first.can_login rescue true) if !site.nil? && (site.site_statuses.first.can_login rescue true)
bundle_update_remote(site) bundle_update_remote(site)
system('sleep 5')
elsif !site.nil? elsif !site.nil?
if site.bundle_update_logs.first.nil? if site.bundle_update_logs.first.nil?
log = site.bundle_update_logs.create() log = site.bundle_update_logs.create()

View File

@ -60,7 +60,7 @@ class RegisteredSite
urls = types.collect do |type| urls = types.collect do |type|
root_url = "#{type}://#{domain}" root_url = "#{type}://#{domain}"
uri0 = URI(root_url) uri0 = URI(root_url)
r = Net::HTTP.start(uri0.host, uri0.port,:use_ssl => uri0.scheme == 'https',open_timeout: 20,read_timeout: 20) do |http| r = Net::HTTP.start(uri0.host, uri0.port,:use_ssl => uri0.scheme == 'https',open_timeout: 20,read_timeout: 20,verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
req = Net::HTTP::Get.new(uri0) req = Net::HTTP::Get.new(uri0)
req['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36' req['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'
http.request req http.request req

View File

@ -312,20 +312,25 @@ fail only
var val = $(this).val() var val = $(this).val()
if (val=='show_all'){ if (val=='show_all'){
$('#detail_div').attr('class','show_ok show_fail') $('#detail_div').attr('class','show_ok show_fail')
$('.table tr').show()
}else if (val=='show_ok_only'){ }else if (val=='show_ok_only'){
$('#detail_div').attr('class','show_ok') $('#detail_div').attr('class','show_ok')
$('.table tr.success').show()
$('.table tr.error').hide()
}else{ }else{
$('#detail_div').attr('class','show_fail') $('#detail_div').attr('class','show_fail')
$('.table tr.success').hide()
$('.table tr.error').show()
} }
}) })
$('th.s0 > input[type=checkbox]').change(function(){ $('th.s0 > input[type=checkbox]').change(function(){
if ($(this).prop('checked')){ if ($(this).prop('checked')){
$('td.s0 > input[type=checkbox]').prop('checked',true) $('td:visible.s0 > input[type=checkbox]').prop('checked',true)
$('td.s0 > input[type=checkbox]').parents('tr').addClass('idle') $('td:visible.s0 > input[type=checkbox]').parents('tr').addClass('idle')
} }
else{ else{
$('td.s0 > input[type=checkbox]').prop('checked',false) $('td:visible.s0 > input[type=checkbox]').prop('checked',false)
$('td.s0 > input[type=checkbox]').parents('tr').removeClass('idle') $('td:visible.s0 > input[type=checkbox]').parents('tr').removeClass('idle')
} }
}) })
$('td.s0 > input[type=checkbox]').change(function(){ $('td.s0 > input[type=checkbox]').change(function(){