使用 Windows 10E ruby 2.3.3p222(2016-11-21 修订版 56859)[i386-mingw32] puma v 2.13.4
我是一个巨大的 PUMA 菜鸟,所以请原谅我。我知道代码(python、php,只是不知道 rails、ruby)
因此,我正在尝试恢复我的好友倾倒给我的旧项目。我已经为此工作了 12 多个小时,我已经走了很长一段路,但我无法克服这个错误......我担心这个决议会超出我的范围,但我试一试:
当我尝试启动应用程序时,我收到此错误:
C:\inetpub\wwwroot\Plex-Board>sh runserver.sh * SIGUSR2 未实现,基于信号的重启不可用!* SIGUSR1 未实现,基于信号的重启不可用!*** SIGHUP 未实施,基于信号的日志重新打开不可用!彪马以单一模式启动...
版本 2.13.4 (ruby 2.3.3-p222),代号:仲夏代码的梦想最小线程:0,最大线程:16 环境:生产!无法加载应用程序:NameError:未初始化的常量 Service::Resolv C:/inetpub/wwwroot/Plex-Board/app/models/service.rb:14:in class:Service':未初始化的常量 Service::Resolv (NameError) from C:/inetpub/wwwroot/Plex-Board/app/models/service.rb:1:in' 来自 C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails /engine.rb:472:in 块(2 级)在 eager_load 中!' 来自 C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:471:ineach' 来自 C:/Ruby23/lib/ruby/gems/2.3。 0/gems/railties-4.2.5/lib/rails/engine.rb:471:in 块在 eager_load 中!来自 C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:469:ineach' 来自 C:/Ruby23/lib/ruby/gems/2.3。0/gems/railties-4.2.5/lib/rails/engine.rb:469:in eager_load!来自 C:ineager_load!来自 C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:56:in each' 来自 C:/Ruby23/lib/ruby/gems /2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:56:inblock in module:Finisher' 来自 C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties -4.2.5/lib/rails/initializable.rb:30:in instance_exec' 来自 C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb: 30:inrun' 来自 C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:55:in block in run_initializers' 来自 C:/Ruby23/lib /ruby/2.3.0/tsort.rb:228:inblock in tsort_each' from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:350:in block (2 levels) in each_strongly_connected_component' from C:/ Ruby23/lib/ruby/2.3.0/tsort.rb:431:ineach_strongly_connected_component_from' 来自 C:/Ruby23/lib/ruby/2.3.0/tsort.rb:349:in 块中 each_strongly_connected_component' 来自 C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:ineach '来自 C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:in call' 来自 C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:ineach_strongly_connected_component' 来自 C:/ Ruby23/lib/ruby/2.3.0/tsort.rb:226:in tsort_each' 来自 C:/Ruby23/lib/ruby/2.3.0/tsort.rb:205:intsort_each' 来自 C:/Ruby23/lib/ruby /gems/2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:54:in run_initializers' 来自 C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2。 5/lib/rails/application.rb:352:初始化!来自 C:/inetpub/wwwroot/Plex-Board/config/environment.rb:5:in '来自 C:/Ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire' 来自 C :/Ruby23/lib/ruby/2.3。
有问题的文件(C:/inetpub/wwwroot/Plex-Board/app/models/service.rb)中有这一行:
class Service < ActiveRecord::Base belongs_to :service_flavor, polymorphic: :true # before_destroy :destroy_associated after_initialize :init
attr_accessor :timeout
strip_attributes only: [:ip, :url, :dns_name], collapse_spaces: true
validates_associated :service_flavor
validates :name, presence: true, uniqueness: true, allow_blank: false
validates :url, presence: true, uniqueness: true, allow_blank: false
validates_inclusion_of :port, in: 1..65535
validates :ip, length: { minimum: 7, maximum: 45 },
format: { with: Resolv::IPv4::Regex },
uniqueness: { scope: :port }, allow_blank: true
validates :dns_name, length: { minimum: 2, maximum: 127 },
uniqueness: { scope: :port }, allow_blank: true
validates :ip, presence: true, if: (:ip_and_dns_name_dont_exist)
validates :dns_name, presence: true, if: (:ip_and_dns_name_dont_exist)
def init
@timeout ||= 5
self.online_status ||= false
end
def ip_and_dns_name_dont_exist
if (ip.blank? || ip.to_s.empty?) && (dns_name.blank? || dns_name.to_s.empty?)
self.errors.add(:base, 'IP Address or DNS Name must exist')
true
else
false
end
end
def ping ping_destination = connect_method begin Timeout.timeout(@timeout) do s = TCPSocket.new(ping_destination, self.port) s.close self.update(online_status: true, last_seen: Time.now) return true end rescue Errno:: ECONNREFUSED self.update(online_status: true, last_seen: Time.now) return true rescue Timeout::Error, Errno::ENETUNREACH, Errno::EHOSTUNREACH, SocketError self.update(online_status: false) return false end end
def connect_method if !self.dns_name.blank? self.dns_name else self.ip end end end
我可以猜到这段代码的作用,但我不确定如何修复它,或者即使可以修复。
苏,有什么想法吗?