Question

I've searched all day for a solution to this and have come up short ... happy for any insight. Thanks in advance.

Issue: log/production.rb file exists but is empty on production Rails 4.0 environment. log/development.rb is as expected on development Rails 4.0 environment.

A little background: Using Rails 4, Ruby 2.0.0-p247, Capistrano 3.0.1, Unicorn 4.7.0 and nginx 1.4.1.

App root and permissions:

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/

So I know log has the same permissions as other directories.

I don't have anything magical in config/environments/production.rb because I assumed Rails will implicitly create logs in production for me. I set config.log_level to :info. (Especially because logs work in dev environment.)

Obviously considering the environment changes the issue must be related to either /log permissions or something blatantly obvious I am missing in the Rails config.

While setting up Capistrano 3 for deployment I used the recommended permissions for the deploy_to path (http://www.capistranorb.com/documentation/getting-started/authentication-and-authorisation/). They wanted chmod -R g+s $deploy_to, so I wonder if this had any affect on the log generation.

I'm open to any solution but would prefer to stick with the built in Rails logs instead of using something else.

Thanks again!

UPDATE: After adding set :linked_dirs, %w{... log ...} to config/deploy.rb the permissions for log appear to be accurate as I am now getting unicorn stdout and stderr in log/unicorn.log.

The issue appears to be related to my unicorn setup as I cannot successful restart or reload the workers.

Contents of app_root/log after Capistrano linked the directories (above):

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
Was it helpful?

Solution 2

This issue was caused by Unicorn failing to start successfully on my web server after updating to Capistrano v3.0.1.

I stripped Unicorn from the app and replaced it with Phusion Passenger. All is well.

OTHER TIPS

Sorry if this is insanely obvious answer, but given that the permissions are the same are you sure that you are running in production?

what happens when you run the following?

  tail -f log/production.log
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top