gpt4 book ai didi

ruby-on-rails - 如何为部署设置服务器并使用 Capistrano 进行冷部署?

转载 作者:数据小太阳 更新时间:2023-10-29 08:09:36 24 4
gpt4 key购买 nike

deploy:setup 的正确方法是什么?并使用 Capistrano 进行冷部署?

使用

这是我的场景:

  1. 运行时deploy:setup , Capistrano 利用 root 权限为部署准备目录结构:

    $ cap deploy:setup
    * 2013-02-28 14:50:21 executing `deploy:setup'
    * executing "sudo -p 'sudo password: ' mkdir -p /home/vagrant/example /home/vagrant/example/releases /home/vagrant/example/shared /home/vagrant/example/shared/system /home/vagrant/example/shared/log /home/vagrant/example/shared/pids"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 29ms
    * executing "sudo -p 'sudo password: ' chmod g+w /home/vagrant/example /home/vagrant/example/releases /home/vagrant/example/shared /home/vagrant/example/shared/system /home/vagrant/example/shared/log /home/vagrant/example/shared/pids"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 11ms
  2. 还在 deploy:cold Capistrano 尝试结帐(在这种情况下来自 git)并写为 vagrant用户 – deploy.rb 中指定的用户:

    $ cap deploy:cold
    * 2013-02-28 14:50:47 executing `deploy:cold'
    * 2013-02-28 14:50:47 executing `deploy:update'
    ** transaction: start
    * 2013-02-28 14:50:47 executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@github.com:mariusbutuc/realtime-faye.git master"
    command finished in 2360ms
    * executing "if [ -d /home/vagrant/example/shared/cached-copy ]; then cd /home/vagrant/example/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard a7c05516bc31c2c18f89057c02f84bfad83a6b59 && git clean -q -d -x -f; else git clone -q git@github.com:mariusbutuc/realtime-faye.git /home/vagrant/example/shared/cached-copy && cd /home/vagrant/example/shared/cached-copy && git checkout -q -b deploy a7c05516bc31c2c18f89057c02f84bfad83a6b59; fi"
    servers: ["example.com"]
    [example.com] executing command
    ** [example.com :: out] fatal: could not create work tree dir '/home/vagrant/example/shared/cached-copy'.: Permission denied
    command finished in 26ms
    *** [deploy:update_code] rolling back
    * executing "rm -rf /home/vagrant/example/releases/20130228195049; true"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 7ms
    failed: "sh -c 'if [ -d /home/vagrant/example/shared/cached-copy ]; then cd /home/vagrant/example/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard a7c05516bc31c2c18f89057c02f84bfad83a6b59 && git clean -q -d -x -f; else git clone -q git@github.com:mariusbutuc/realtime-faye.git /home/vagrant/example/shared/cached-copy && cd /home/vagrant/example/shared/cached-copy && git checkout -q -b deploy a7c05516bc31c2c18f89057c02f84bfad83a6b59; fi'" on example.com
  3. 当然,deploy:check报告毫不意外:vagrant用户无法写入在 deploy:setup 期间创建的目录因为这两个用户属于不同的组 – root:rootvagrant:vagrant :

    $ cap deploy:check
    [...]
    The following dependencies failed. Please check them and try again:
    --> You do not have permissions to write to `/home/vagrant/example'. (example.com)
    --> You do not have permissions to write to `/home/vagrant/example/releases'. (example.com)
    --> `/home/vagrant/example/shared' is not writable (example.com)

这背后的原因是什么,还没有满足什么先决条件,所以部署通过了这个问题?

最佳答案

deploy:setup任务可能不应该使用 sudo创建 app 目录,因为这可能导致它被 root 拥有.

您可以在 deploy.rb 中将其关闭文件:

set :use_sudo, false

关于ruby-on-rails - 如何为部署设置服务器并使用 Capistrano 进行冷部署?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15144815/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com