JonleePeakman
JonleePeakman

Reputation: 679

Unicorn working on development not in production

So I am following the nginx/unicorn railscast and have been having trouble getting my app with production setting(very basic app with just a welcome#index controller and root route I run the following

unicorn -c /home/jonlee/sites/localstyling/config/unicorn.rb

Unicorn boots up and starts logging all activity to my screen when refreshing the browser

When I add the production environment flag:

unicorn -c /home/jonlee/sites/localstyling/config/unicorn.rb -E production

Unicorn boots up, and when refreshing the browser no activity shows in the console but the welcome page is still shown. Checking the logs I see:

Rendered welcome/index.html.erb within layouts/application (3.3ms)
Completed 200 OK in 133ms (Views: 24.1ms | ActiveRecord: 0.0ms)
Started GET "/stylesheets/application.css" for 127.0.0.1 at 2014-07-04 08:18:53 +0100
ActionController::RoutingError (No route matches [GET] "/stylesheets/application.css")
..
..
..

I guess my production.rb file is the problem, I have tried setting config.serve_static_assets = true and this hasn't helped. My production.rb is as follows:

Rails.application.configure do
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = true
  config.assets.js_compressor = :uglifier
  config.assets.compile = true
  config.assets.digest = true
  config.log_level = :info
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
end

I'm not instantly seeing anything wrong and I do not understand why I am not getting any output from the console when running unicorn -E production, any thoughts would be appreciated.

Upvotes: 0

Views: 621

Answers (1)

JonleePeakman
JonleePeakman

Reputation: 679

Production logs to log/production.log only and before this will work you need to precompile the assets

RAILS_ENV=production rake assets:precompile

and set in the /config/environments.production.rb file

config.server_static_assets = true

Upvotes: 1

Related Questions