Rails-Capistrano和chmod [英] Rails - capistrano and chmod
问题描述
我想通过capistrano使用chmod为文件夹添加权限。例如,我要这样做:
I want to use chmod via capistrano to add permission for folder. For example, i want to do that:
chmod 777 -R /vol/www/apps/ror_tutorial/current/log/
所以,我想通过capistrano的任务来做到这一点。我尝试过:
So, i want to do that via capistrano's task. I tried that:
desc "Fix permission"
task :fix_permissions, :roles => [ :app, :db, :web ] do
run "#{try_sudo} chmod 777 -R #{current_path}/log"
end
after "deploy:update_code", :fix_permissions
但它不起作用。文件夹的权限是相同的:
But it doesn't work. Permissions of the folder are same:
$ ls -alh /vol/www/apps/ror_tutorial/current/log/
total 1008K
drwxrwxrwx 2 root root 4.0K 2012-02-03 20:22 .
drwxrwxr-x 7 root root 4.0K 2012-01-25 20:50 ..
-rwxrwxrwx 1 root root 419K 2012-02-03 14:35 development.log
-rwxrwxrwx 1 root root 530K 2012-02-03 20:16 production.log
-rwxrwxrwx 1 root root 0 2012-02-02 14:21 searchd.development.pid
-rwxrwxrwx 1 root root 15K 2012-02-03 20:22 searchd.log
-rw------- 1 root root 6 2012-02-03 20:22 searchd.production.pid
-rwxrwxrwx 1 root root 19K 2012-02-03 18:07 searchd.query.log
如果我尝试通过ssh手动打印chmod作品:
If i try to print chmod manually via ssh it works:
$ chmod 777 -R /vol/www/apps/ror_tutorial/current/log/
$ ls -alh /vol/www/apps/ror_tutorial/current/log/
total 1008K
drwxrwxrwx 2 root root 4.0K 2012-02-03 20:22 .
drwxrwxr-x 7 root root 4.0K 2012-01-25 20:50 ..
-rwxrwxrwx 1 root root 419K 2012-02-03 14:35 development.log
-rwxrwxrwx 1 root root 530K 2012-02-03 20:16 production.log
-rwxrwxrwx 1 root root 0 2012-02-02 14:21 searchd.development.pid
-rwxrwxrwx 1 root root 15K 2012-02-03 20:22 searchd.log
-rwxrwxrwx 1 root root 6 2012-02-03 20:22 searchd.production.pid
-rwxrwxrwx 1 root root 19K 2012-02-03 18:07 searchd.query.log
我如何为capistrano编写正确的任务?
How can i write right task for capistrano to do that?
推荐答案
在deploy:symlink之后尝试将钩子更改为,我认为您正在更新上一个当前目录中的权限。附带说明:deploy:symlink将很快更改为deploy:create_symlink,如果在将capistrano升级到2.10或更高版本后此操作中断,请记住这一点。
Try changing the hook to after deploy:symlink, I think you are updating permissions in the 'previous' current dir. On a side note: deploy:symlink will soon change to deploy:create_symlink, keep that in mind if this breaks after upgrading capistrano to 2.10 or higher.
这篇关于Rails-Capistrano和chmod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!