File creation mode in Rails + Unicorn

Jérémy Lecour jeremy.lecour at gmail.com
Fri Jun 8 11:29:06 UTC 2012


Le 8 juin 2012 à 11:20, Eric Wong a écrit :

> Jérémy Lecour <jeremy at autrementlemail.fr> wrote:
>> 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
> 
> Did you also use sudo to start webrick?

I didn't, and that seems to make the difference.

> You can use:   printf("0%o", File.umask)   to show the current umask, too.

root # sudo -u deploy irb
irb> printf("0%o", File.umask)
077

deploy # irb
irb> printf("0%o", File.umask)
027


Thanks for your help, you nailed it.


Jérémy Lecour
Conception et développement d'applications web
06 22 43 88 94 - http://jeremy.wordpress.com - http://twitter.com/jlecour



More information about the mongrel-unicorn mailing list