简体   繁体   English

Ruby PUMA错误:“无法加载应用程序:NameError:未初始化的常量Service :: Resolv”

[英]Ruby PUMA error: “Unable to load application: NameError: uninitialized constant Service::Resolv”

Using Windows 10E ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32] puma v 2.13.4 使用Windows 10E ruby​​ 2.3.3p222(2016-11-21修订版56859)[i386-mingw32] puma v 2.13.4

I'm a HUGE PUMA noob, so please excuse me. 我是一个巨大的PUMA菜鸟,所以请原谅。 I know code (python, php, just not rails, ruby) 我知道代码(python,php,只是不是rails,ruby)

So, I'm trying to revive an old project my buddy dumped off to me. 所以,我正在努力恢复我的伙伴抛弃给我的旧项目。 I've been working at this for 12+ hours and I've come a long way, but I can't get past this error...and I'm afraid the resolution is gonna be out of my league, but I'll give it a shot: 我已经在这里工作了12个多小时而且我已经走了很长一段路,但是我无法克服这个错误...而且我担心这个决议将会超出我的联盟,但是我试一试:

When I try to launch the application, I get this error: 当我尝试启动应用程序时,我收到此错误:

C:\\inetpub\\wwwroot\\Plex-Board>sh runserver.sh * SIGUSR2 not implemented, signal based restart unavailable! C:\\ inetpub \\ wwwroot \\ Plex-Board> sh runserver.sh * SIGUSR2未实现,基于信号的重启不可用! * SIGUSR1 not implemented, signal based restart unavailable! * SIGUSR1未实现,基于信号的重启不可用! *** SIGHUP not implemented, signal based logs reopening unavailable! *** SIGHUP未实现,基于信号的日志重新开启不可用! Puma starting in single mode... Puma以单一模式开始......

Version 2.13.4 (ruby 2.3.3-p222), codename: A Midsummer Code's Dream Min threads: 0, max threads: 16 Environment: production ! 版本2.13.4(ruby 2.3.3-p222),代号:A仲夏代码的Dream Min线程:0,最大线程数:16环境:生产! Unable to load application: NameError: uninitialized constant Service::Resolv C:/inetpub/wwwroot/Plex-Board/app/models/service.rb:14:in class:Service': uninitialized constant Service::Resolv (NameError) from C:/inetpub/wwwroot/Plex-Board/app/models/service.rb:1:in' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:472:in block (2 levels) in eager_load!' 无法加载应用程序:NameError:uninitialized constant Service :: Resolv C:/inetpub/wwwroot/Plex-Board/app/models/service.rb:14:in class:Service':uninitialized constant Service :: Resolv(NameError)from C:/inetpub/wwwroot/Plex-Board/app/models/service.rb:1:in"from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails /engine.rb:472:in eager_load中的块(2级)!' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:471:ineach' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:471:in block in eager_load!' 来自C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:471:inach'来自C:/Ruby23/lib/ruby/gems/2.3。 0 / gems / railties-4.2.5 / lib / rails / engine.rb:471:在eager_load块中! from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:469:ineach' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:469:in eager_load!' 来自C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:469:inach'来自C:/Ruby23/lib/ruby/gems/2.3。 0 / gems / railties-4.2.5 / lib / rails / engine.rb:469:in eager_load!' from C:ineager_load!' 来自C:ineager_load!' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:56:in each' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:56:inblock in module:Finisher' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in instance_exec' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:inrun' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:55:in block in run_initializers' from 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' from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:349:in block in each_strongly_connected_component' from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:ineach' from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:in call' from C:/Ruby23/lib/ruby/ 来自C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:56:在每个'来自C:/ Ruby23 / lib / ruby​​ / gems /2.3.0/gems/railties-4.2.5/lib/rails/application/finisher.rb:56:inblock in module:Finisher'from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties -4.2.5 / lib / rails / initializable.rb:30:in实例_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'from 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:inach_strongly_connected_component_from'from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:349:inclock in each_strongly_connected_component'from C:/ Ruby23 / lib /ruby/2.3.0/tsort.rb:347:ineach'来自C:/Ruby23/lib/ruby/2.3.0/tsort.rb:347:来自C:/ Ruby23 / lib / ruby​​ / 2.3.0/tsort.rb:347:ineach_strongly_connected_component' from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:226:in tsort_each' from C:/Ruby23/lib/ruby/2.3.0/tsort.rb:205:intsort_each' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:54:in run_initializers' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/application.rb:352:ininitialize!' 2.3.0 / tsort.rb:347:inach_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 /红宝石/宝石/ 2.3.0 /宝石/ railties-4.2.5 / lib目录/导轨/ application.rb中:352:ininitialize“! from C:/inetpub/wwwroot/Plex-Board/config/environment.rb:5:in ' from C:/Ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from C:/Ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from config.ru:3:inblock in ' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/rack/builder.rb:184:in instance_eval' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/rack/builder.rb:184:ininitialize' from config.ru:in new' from config.ru:in' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/rack/builder.rb:170:in eval' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/rack/builder.rb:170:innew_from_string' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/rack/builder.rb:161:in parse_file' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/configuration.rb:129:inload_rackup' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/configuration.rb:96:in app' from C:/Ruby23/lib/ruby/gems/2.3.0/ge 来自C:/inetpub/wwwroot/Plex-Board/config/environment.rb:5:in"from C:/Ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'来自C :/Ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:在'来自c:/Ruby23/lib/ruby/gems/2.3.0的'来自config.ru:3:inblock'中/gems/puma-2.13.4/lib/puma/rack/builder.rb:184:in instance_eval'来自C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/ puma / rack / builder.rb:184:ininitialize'from config.ru:in new'from config.ru:in'from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4 /lib/puma/rack/builder.rb:170:in eval'来自C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/rack/builder.rb: 170:innew_from_string'来自C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/rack/builder.rb:161:来自C:/ Ruby23 / lib的parse_file' /ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/configuration.rb:129:inload_rackup'来自C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13 .4 / lib / puma / configuration.rb:96:in app'from C:/Ruby23/lib/ruby/gems/2.3.0/ge ms/puma-2.13.4/lib/puma/runner.rb:113:inload_and_bind' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/single.rb:79:in run' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/cli.rb:215:inrun' from C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/bin/puma:10:in ' from C:/Ruby23/bin/puma:22:inload' from C:/Ruby23/bin/puma:22:in `' ms / puma-2.13.4 / lib / puma / runner.rb:113:来自C:/Ruby23 / lib / ruby rb:79:运行'来自C:/Ruby23/lib/ruby/gems/2.3.0/gems/puma-2.13.4/lib/puma/cli.rb:215:inrun'来自C:/ Ruby23 / lib /ruby/gems/2.3.0/gems/puma-2.13.4/bin/puma:10:in来自C:/ Ruby23 / bin / puma:22:inload'来自C:/ Ruby23 / bin / puma:22 :在''

The file in question ( C:/inetpub/wwwroot/Plex-Board/app/models/service.rb) has this line in it: 有问题的文件(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 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 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)返回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? def connect_method if!self.dns_name.blank? self.dns_name else self.ip end end end self.dns_name else self.ip end end end


I can guess what this code does, but I'm not sure how to fix it or even if it's possible to fix. 我可以猜出这段代码是做什么的,但我不确定如何解决它,或者即使它可以修复。

Sooo, any ideas? Sooo,任何想法?

Try in rails console, to check this class is loaded or not 尝试使用rails控制台,检查此类是否已加载

Resolv::IPv4::Regex . Resolv::IPv4::Regex

If not then you should need to add 如果没有,那么你应该添加

gem 'rubysl-resolv'

in your Gemfile and then bundle install 在您的Gemfile中然后捆绑安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM