簡體   English   中英

無法運行Rails服務器

[英]Can't run Rails server

我嘗試使用rails運行服務器時遇到問題

我正在使用Windows,這是返回值:

C:\Blog\MyBlog>rails s
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:353:in `kill': Invalid argument (Errno::EINVAL)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:353:in `pidfile_process_status'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:340:in `check_pid!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:246:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

C:\Blog\MyBlog>

我的gemfile:

來源' https://rubygems.org '

 gem 'rails', '3.2.12' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' # To use Jbuilder templates for JSON # gem 'jbuilder' # Use unicorn as the app server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'debugger' 

紅寶石 1.9.3p392(2013-02-22)[i386-mingw32], Rails 3.2.12, Gem 1.8.25

對不起我的英國人

已編輯

我嘗試使用雜種,但我在cmd中得到了下一個:

C:\Blog\MyBlog>rails s mongrel
Exiting
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/handler/mongrel.rb:1:in
`require': cannot load such file -- mongrel (LoadError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/handler/mon
grel.rb:1:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/handler.rb:
20:in `const_get'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/handler.rb:
20:in `block in get'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/handler.rb:
20:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/handler.rb:
20:in `inject'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/handler.rb:
20:in `get'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:2
72:in `server'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/comma
nds/server.rb:59:in `start'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/comma
nds.rb:55:in `block in <top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/comma
nds.rb:50:in `tap'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.12/lib/rails/comma
nds.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

嘗試在tmp / pids / server.pid文件中添加一個隨機編號(例如6532),然后啟動webricks

Windows和Rails通常無法在其他環境中正常工作。 帶有Rails的Windows中,Webbrick的最佳解決方法是安裝另一台服務器進行開發。 雜種是一個很好的選擇。 要安裝它:

gem install mongrel

然后啟動服務器

rails s mongrel

我遇到了同樣的問題。 我發現最簡單的解決方法實際上是刪除應用程序文件夾中的現有pid文件:

del tmp\pids\*.*

找到了參考以下資源的解決方案:[ https://github.com/rack/rack/issues/544] [1 ]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM