ruby-on-rails - log/production.log 文件存在但为空

标签 ruby-on-rails ruby nginx permissions unicorn

<分区>

我一整天都在寻找解决方案,但都没有找到答案……很高兴有任何见解。提前致谢。

问题:log/production.rb 文件存在但在生产 Rails 4.0 环境中为空。 log/development.rb 在开发 Rails 4.0 环境中符合预期。

一些背景知识:使用 Rails 4、Ruby 2.0.0-p247、Capistrano 3.0.1、Unicorn 4.7.0 和 nginx 1.4.1。

应用根目录和权限:

drwxrwsr-x 13 deployer deployer 4096 2013-11-10 21:30 ./
drwxrwsr-x  7 deployer deployer 4096 2013-11-10 21:30 ../
drwxrwsr-x  8 deployer deployer 4096 2013-11-10 21:31 app/
-rw-rw-r--  1 deployer deployer 2015 2013-11-10 21:30 assets_manifest_backup
drwxrwsr-x  2 deployer deployer 4096 2013-11-10 21:31 bin/
drwxrwsr-x  2 deployer deployer 4096 2013-11-10 21:30 .bundle/
-rw-rw-r--  1 deployer deployer  473 2013-11-10 21:31 Capfile
drwxrwsr-x  6 deployer deployer 4096 2013-11-10 21:30 config/
-rw-rw-r--  1 deployer deployer  154 2013-11-10 21:31 config.ru
drwxrwsr-x  3 deployer deployer 4096 2013-11-10 21:31 db/
-rw-rw-r--  1 deployer deployer 1378 2013-11-10 21:31 Gemfile
-rw-rw-r--  1 deployer deployer 3418 2013-11-10 21:31 Gemfile.lock
-rw-rw-r--  1 deployer deployer  488 2013-11-10 21:31 .gitignore
drwxrwsr-x  5 deployer deployer 4096 2013-11-10 21:31 lib/
drwxrwsr-x  2 deployer deployer 4096 2013-11-10 21:30 log/
drwxrwsr-x  2 deployer deployer 4096 2013-11-10 21:30 public/
-rw-rw-r--  1 deployer deployer  249 2013-11-10 21:31 Rakefile
-rw-rw-r--  1 deployer deployer 3165 2013-11-10 21:31 README.md
drwxrwsr-x  8 deployer deployer 4096 2013-11-10 21:31 test/
drwxrwsr-x  3 deployer deployer 4096 2013-11-10 21:30 tmp/
drwxrwsr-x  3 deployer deployer 4096 2013-11-10 21:31 vendor/

所以我知道 log 与其他目录具有相同的权限。

我在 config/environments/production.rb 中没有任何神奇的东西,因为我假设 Rails 会隐式地为我创建生产日志。我将 config.log_level 设置为 :info。 (特别是因为日志在开发环境中工作。)

显然,考虑到环境变化,问题必须与/log 权限或我在 Rails 配置中明显缺失的东西有关。

在为部署设置 Capistrano 3 时,我使用了 deploy_to 路径的推荐权限 (http://www.capistranorb.com/documentation/getting-started/authentication-and-authorisation/)。他们想要 chmod -R g+s $deploy_to,所以我想知道这是否对日志生成有任何影响。

我对任何解决方案持开放态度,但宁愿坚持使用内置的 Rails 日志,而不是使用其他东西。

再次感谢!

更新:在将 set :linked_dirs, %w{... log ...} 添加到 config/deploy.rb 后,日志的权限似乎是准确的因为我现在在 log/unicorn.log 中获取 unicorn stdout 和 stderr。

问题似乎与我的 unicorn 设置有关,因为我无法成功重启或重新加载工作人员。

Capistrano 链接目录后 app_root/log 的内容(上图):

drwxr-sr-x 2 deployer deployer  4096 2013-11-11 06:23 ./
drwxrwsr-x 9 deployer deployer  4096 2013-11-11 06:20 ../
-rw-r--r-- 1 deployer deployer     0 2013-11-11 06:20 production.log
-rw-r--r-- 1 deployer deployer 11570 2013-11-11 07:09 unicorn.log

最佳答案

很抱歉,如果这是一个非常明显的答案,但鉴于权限是相同的,您确定您正在生产环境中运行吗?

当您运行以下命令时会发生什么?

  tail -f log/production.log

关于ruby-on-rails - log/production.log 文件存在但为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19899116/

相关文章:

ssl - 将我的站点 cert.key 和 cert.pem 放在 Nginx Docker 容器中是一种好习惯吗?

ruby-on-rails - 如何在 Ruby on Rails 中获取已保存记录的 id

compilation - 警告 : Nokogiri was built against LibXML version 2. 7.7,但已动态加载 2.6.16

css - Rails 在哪里包含 @media css 标签?

php - 在未启用远程 SQL 访问的情况下将数据从本地 SQL 数据库放入远程 SQL 数据库 (PHP)

arrays - Ruby - 数组交集(有重复项)

sql - Rails 用于创建和更新操作的唯一订单字段

docker compose 覆盖端口属性而不是合并它

ruby-on-rails - xmpp 服务器和 ruby​​ on rails 集成建议?

NGINX - 在没有 ssl 证书的情况下从 https 重定向到 http