开发者

Ruby on Rails application not regenerating stylesheets on deploy

I have a Ruby on Rails application that is not generating stylesheets properly. Sometimes SASS doesn't compile the SCSS into CSS and sometimes they concatenated CSS are not generated. I basically get an error writing the files, like this:

Error Message:
Errno::EACCES: Permission denied - /var/www/app/releases/20101004114929/public/stylesheets/cached_tutor24_tutor24-dot-ch-dot-simplificator-dot-com.css

Where:
pages#show
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb, line 673

Backtrace Summary:
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `initialize'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `open'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:673:in `write_asset_file_contents'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/helpers/asset_tag_helper.rb:433:in `stylesheet_link_tag'
[PROJECT_ROOT]/app/helpers/application_helper.rb:28:in `robust_stylesheet_link_tag'
[PROJECT_ROOT]/app/views/layouts/application.html.haml:28:in `_run_haml_app47views47layouts47application46html46haml'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `send'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `render_without_trace_View_path_r_2_Rendering'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:306:in `with_template'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/renderable.rb:30:in `render_without_trace_View_path_r_2_Rendering'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:319:in `render'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:141:in `trace_execution_scoped'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:314:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/template.rb:205:in `render_template'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:265:in `render_without_haml'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:352:in `_render_with_layout'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_view/base.rb:262:in `render_without_haml'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1250:in `render_for_file'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:936:in `render_without_benchmark'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1326:in `default_render'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:1332:in `perform_action_without_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:617:in `call_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/flash.rb:151:in `perform_action_without_newrelic_trace'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/control/./agent/instrumentation/controller_instrumentation.rb:254:in `perform_action'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/agent/method_tracer.rb:141:in `trace_execution_scoped'
[GEM_ROOT]/gems/newrelic_rpm-2.13.1/lib/new_relic/control/./agent/instrumentation/controller_instrumentation.rb:247:in `perform_action'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `send'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `process_without_filters'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/filters.rb:606:in `process'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:391:in `process'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/base.rb:386:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:438:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:87:in `dispatch'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:121:in `_call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/sass/plugin/rack.rb:41:in `call'
[GEM_ROOT]/gems/haml-3.0.18/rails/./lib/sass/plugin/rack.rb:41:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/string_coercion.rb:25:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/params_parser.rb:15:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/session/abstract_store.rb:177:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:29:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:9:in `cache'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:28:in `call'
[GEM_ROOT]/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/failsafe.rb:26:in `call'
[GEM_ROOT]/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:106:in `call'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/utils.rb:252:in `safe_fork'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:163:in `start'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:247:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_开发者_JAVA百科manager.rb:145:in `spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

The whole /var/www/app is set to belong to www-data:www-data with permissions ug+rwX, a couple of times at deploy time.

Even after deploying I can go and check the permissions and they are fine:

# ls -la current/public/stylesheets/
total 92
drwxrwxr-x 2 www-data www-data  4096 Oct  4 14:11 ./
drwxrwxr-x 6 www-data www-data  4096 Oct  4 13:49 ../

and it still fails to create (or read the files).

Any ideas what might be going on?


  1. Does webserver really run as www-data user?
  2. Aren't there some FS errors? (dmesg)
  3. Does 'current' symlink point to the same directory under 'releases' that is shown in trace?
  4. What happens if you change permissions on current/public/stylesheets to 777?


Your app is probably not running as www-data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜