File creation mode in Rails + Unicorn

Jérémy Lecour jeremy at autrementlemail.fr
Fri Jun 8 08:39:45 UTC 2012


Hi,

I'm currently giving Nginx + Unicorn a try, to eventually replace Apache + Passenger. So far so good.

I have a Rails 3.2.5 app behind Unicorn, itself behind Nginx.
In this Rails app, I have set page caching for some resources. They are created in Rails.root/public/ to be directly available to Nginx.

When I first hit such a page, the static cache file is not present, so the Rails app is reached and the file is created.
The next hit is a 403 error.
The file is created with the right user/group but in 0600 mode instead of 0660 or 0640, that's why I have this error.

If I start my app with Webrick instead of Unicorn, the file is created the mode is alright.


To start Unicorn, my init script (executed by root) does something like this (let's say that the user/group is deploy/deploy) :

    sudo -u deploy unicorn -E production -c RAILS_ROOT/config/unicorn.rb -D

Then in the unicorn.rb config script I have set this :

   user 'deploy', 'deploy'


I've tried to use unicorn in socket or TCP mode, but I get the same result.

Thanks for any help and for making Unicorn such an awesome tool.

Jérémy Lecour
http://twitter.com/jlecour


More information about the mongrel-unicorn mailing list