Jak Mogę używać unicorn jako "rails s"?
A new rails project ' s Gemfile
pokazuje:
# Use unicorn as the app server
gem 'unicorn'
rails s --help
pokazuje:
Usage: rails server [mongrel, thin, etc] [options]
JESZCZE, ROBI:
rails s unicorn
Otrzymuję:
/Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/rack-1.4.5/lib/rack/handler.rb:63:in `require': cannot load such file -- rack/handler/unicorn (LoadError)
from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/rack-1.4.5/lib/rack/handler.rb:63:in `try_require'
from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/rack-1.4.5/lib/rack/handler.rb:16:in `get'
from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/rack-1.4.5/lib/rack/server.rb:272:in `server'
from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/railties-3.2.13/lib/rails/commands/server.rb:59:in `start'
from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Używałem unicorn w przeszłości w innych projektach, ale zawsze musiałem uruchomić polecenie unicorn
i podać plik konfiguracyjny, który jest trochę uciążliwy. Zastanawiam się, jak mogę po prostu sprawić, by działało za pomocą rails s...
5 answers
Wygląda na to, że unicorn-rails
gem, o którym wspomniał @ Dogbert, może być użyty do uczynienia z Unicorna Handlera rails server
.
Po prostu dołącz gem "unicorn-rails"
(i dla Rails 4.2.4, gem "rack-handlers"
) do swojego Gemfile
, Uruchom bundle install
, aby zainstalować gem, następnie możesz uruchomić:
$ rails server unicorn
Chociaż po zainstalowaniu unicorn-rails
Unicorn powinien być domyślnym serwerem aplikacji, więc możesz po prostu uruchomić rails server
i użyć Unicorn (zakładając, że nie masz również Thin lub Mongrel w swoim Gemfile
, W takim przypadku mogą konflikt i możesz chcieć usunąć te, których nie używasz).
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-09-18 18:42:01
Lepszą opcją może być bezpośrednie uruchomienie serwera unicorn.
bundle exec unicorn -p 3000 # default port is 8080
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-01 02:31:07
gem 'rack-handlers'
rails server unicorn
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-11 14:36:35
Myślę, że nie jest możliwe użycie unicorn jako 'rails s'. Użyj tego -
Dodaj gem 'unicorn' do pliku gem i uruchom bundle install.
A następnie uruchom jedną z następujących komend -
$ unicorn-p 3000
LUB
$ unicorn_rails-p 3000
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-12-28 16:29:39
Jednak odpowiedź przez {[1] } jest najprostszym sposobem.
Uruchamiam unicorn
w środowisku programistycznym poprzez zadanie rake:
Lib / tasks / dev_unicorn."grabie": {]}
task :server do
# optional port parameter
port = ENV['PORT'] ? ENV['PORT'] : '3000'
puts 'start unicorn development'
# execute unicorn command specifically in development
# port at 3000 if unspecified
sh "cd #{Rails.root} && RAILS_ENV=development unicorn -p #{port}"
end
# an alias task
task :s => :server
Run:
rake s
Numer referencyjny http://jing.io
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-12 16:08:10