Rails - capistrano and chmod

十年热恋 提交于 2019-12-07 16:03:53

问题


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/

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

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

How can i write right task for capistrano to do that?


回答1:


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.



来源:https://stackoverflow.com/questions/9133367/rails-capistrano-and-chmod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!