【问题标题】:Ruby on Rails application not regenerating stylesheets on deployRuby on Rails 应用程序不会在部署时重新生成样式表
【发布时间】:2011-04-20 18:49:27
【问题描述】:

我有一个 Ruby on Rails 应用程序无法正确生成样式表。有时 SASS 不会将 SCSS 编译成 CSS,有时它们连接的 CSS 不会生成。我基本上在写入文件时遇到错误,如下所示:

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_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'

整个 /var/www/app 被设置为属于 www-data:www-data 权限为 ug+rwX,在部署时执行几次。

即使在部署之后,我也可以去检查权限,它们很好:

# 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 ../

它仍然无法创建(或读取文件)。

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails deployment passenger sass


    【解决方案1】:
    1. 网络服务器真的以 www-data 用户身份运行吗?
    2. 是不是有一些 FS 错误? (dmesg)
    3. “当前”符号链接是否指向跟踪中显示的“发布”下的同一目录?
    4. 如果您将当前/公共/样式表的权限更改为 777,会发生什么情况?

    【讨论】:

    • 1:是的,确实如此;我检查了以防万一。明天我回到办公室后,我将在 2、3 和 4 点工作。感谢您的回答。
    • 2:没有文件系统错误。 3:是的,是同一个目录。 4:我已将它添加到我们的部署过程中,它开始工作,我删除它,它继续工作......所以不确定。
    【解决方案2】:

    【讨论】:

    • 嗯,它应该作为 www-data 运行,因为它是 config/environment.rb 的所有者。在很短的一段时间内,所有者是 root 并且确实乘客以 root 身份运行,尽管文档说它永远不会以 root 身份运行。
    • Phusion Passenger 可以以 root 身份运行一些内部帮助进程,但应用程序本身,例如所有“Rails: ...”和“Rack: ...”进程都不会以 root 身份运行。根据 ps,它们在运行什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-15
    • 1970-01-01
    • 2018-06-10
    • 2012-06-21
    • 2016-01-06
    • 2016-06-23
    • 2015-10-22
    相关资源
    最近更新 更多