为什么我的 Capistrano 失败了?

发布于 2024-12-28 11:57:39 字数 6185 浏览 0 评论 0原文

好的,我有一个新的 ec2 实例,所有设置都已完成,我与用户 ec2-user 进行 ssh 连接,并在我的本地计算机上运行检查命令,

cap deploy:check
  * executing `deploy:check'
  * executing "test -d /var/www/projects/releases"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 101ms
  * executing "test -w /var/www/projects"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 106ms
  * executing "test -w /var/www/projects/releases"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 103ms
  * executing "which git"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 104ms
You appear to have all necessary dependencies installed

我最后收到此错误

 [50.19.84.170] executing command
    command finished in 150ms
failed: "sh -c 'rm -f /var/www/projects/current && ln -s /var/www/projects/releases/20120123133717 /var/www/projects/current'" on 50.19.84.170

一切似乎都正常,但是当我进行 cap 部署时, 我看看releases目录中是否有任何东西,但没有什么

 ls -la /var/www/projects/releases/total 8
drwxrwxr-x 2 ec2-user ec2-user 4096 Jan 23 13:37 .
drwxrwxr-x 5 ec2-user ec2-user 4096 Jan 20 03:03 ..

不确定我做错了什么...这是我的deploy.rb

set :application, "projects"
set :deploy_to, "/var/www/#{application}"
set :keep_releases, 3

set :scm, :git
set :repository,  "[email protected]:railsdevmatt/fat_free_crm.git"
set :git_shallow_clone, 1
set :branch, "master"
set :use_sudo, true

set :user, "ec2-user"
ssh_options[:forward_agent] = true
default_run_options[:pty] = true

role :app, "50.19.84.170"
role :web, "50.19.84.170"
role :db,  "50.19.84.170", :primary => true

after "deploy:setup", :fix_perms
after "deploy:update_code", :fix_perms

# ssh_options[:keys] = ["#{ENV['HOME']}/Downloads/important.pem"]

task :fix_perms do
  # sudo "chown apache:webshare -R /var/www/projects"
  # sudo "chmod 666 -R /var/www/projects/shared/log/*"
end

任何想法我需要更改

更新

这是我的整个输出

cap deploy
  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote [email protected]:railsdevmatt/fat_free_crm.git master"
/Library/Ruby/Gems/1.8/gems/capistrano-2.6.0/lib/capistrano/recipes/deploy.rb:104: warning: Insecure world writable dir /Users/mattelhotiby in PATH, mode 040777
    command finished in 1061ms
  * executing "git clone -q --depth 1 [email protected]:railsdevmatt/fat_free_crm.git /var/www/projects/releases/20120123144652 && cd /var/www/projects/releases/20120123144652 && git checkout -q -b deploy 65b439e201c2134fc97ee10a4ea66174018d8553 && (echo 65b439e201c2134fc97ee10a4ea66174018d8553 > /var/www/projects/releases/20120123144652/REVISION)"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 1898ms
  * executing `deploy:finalize_update'
  * executing "chmod -R g+w /var/www/projects/releases/20120123144652"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 123ms
  * executing "rm -rf /var/www/projects/releases/20120123144652/log /var/www/projects/releases/20120123144652/public/system /var/www/projects/releases/20120123144652/tmp/pids &&\\\n      mkdir -p /var/www/projects/releases/20120123144652/public &&\\\n      mkdir -p /var/www/projects/releases/20120123144652/tmp &&\\\n      ln -s /var/www/projects/shared/log /var/www/projects/releases/20120123144652/log &&\\\n      ln -s /var/www/projects/shared/system /var/www/projects/releases/20120123144652/public/system &&\\\n      ln -s /var/www/projects/shared/pids /var/www/projects/releases/20120123144652/tmp/pids"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 133ms
  * executing "find /var/www/projects/releases/20120123144652/public/images /var/www/projects/releases/20120123144652/public/stylesheets /var/www/projects/releases/20120123144652/public/javascripts -exec touch -t 201201231446.55 {} ';'; true"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
 ** [out :: 50.19.84.170] find: `/var/www/projects/releases/20120123144652/public/images': No such file or directory
 ** [out :: 50.19.84.170] find: `/var/www/projects/releases/20120123144652/public/stylesheets': No such file or directory
 ** [out :: 50.19.84.170] find: `/var/www/projects/releases/20120123144652/public/javascripts': No such file or directory
    command finished in 111ms
    triggering after callbacks for `deploy:update_code'
  * executing `fix_perms'
  * executing "sudo -p 'sudo password: ' chown apache:webshare -R /var/www/projects"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 136ms
  * executing "sudo -p 'sudo password: ' chmod 666 -R /var/www/projects/shared/log/*"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
 ** [out :: 50.19.84.170] chmod: cannot access `/var/www/projects/shared/log/*': No such file or directory
    command finished in 119ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/projects/releases/20120123144652; true"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 145ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' chmod 666 -R /var/www/projects/shared/log/*'" on 50.19.84.170

这里是该目录

 ls -la /var/www/projects/shared/
total 20
drwxrwxr-x 5 apache webshare 4096 Jan 23 13:32 .
drwxrwxr-x 5 apache webshare 4096 Jan 20 03:03 ..
drwxrwxr-x 2 apache webshare 4096 Jan 20 03:31 log
drwxrwxr-x 2 apache webshare 4096 Jan 23 13:32 pids
drwxrwxr-x 2 apache webshare 4096 Jan 23 13:32 system

Ok so i have a new ec2 instance that is all setup and i ssh in with the user ec2-user and on my local machine i ran the check command

cap deploy:check
  * executing `deploy:check'
  * executing "test -d /var/www/projects/releases"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 101ms
  * executing "test -w /var/www/projects"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 106ms
  * executing "test -w /var/www/projects/releases"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 103ms
  * executing "which git"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 104ms
You appear to have all necessary dependencies installed

All seems ok there but when i do cap deploy i get this error at the end

 [50.19.84.170] executing command
    command finished in 150ms
failed: "sh -c 'rm -f /var/www/projects/current && ln -s /var/www/projects/releases/20120123133717 /var/www/projects/current'" on 50.19.84.170

then i see if anything is in the releases directory and nothing

 ls -la /var/www/projects/releases/total 8
drwxrwxr-x 2 ec2-user ec2-user 4096 Jan 23 13:37 .
drwxrwxr-x 5 ec2-user ec2-user 4096 Jan 20 03:03 ..

not sure what i am doing wrong ...here is my deploy.rb

set :application, "projects"
set :deploy_to, "/var/www/#{application}"
set :keep_releases, 3

set :scm, :git
set :repository,  "[email protected]:railsdevmatt/fat_free_crm.git"
set :git_shallow_clone, 1
set :branch, "master"
set :use_sudo, true

set :user, "ec2-user"
ssh_options[:forward_agent] = true
default_run_options[:pty] = true

role :app, "50.19.84.170"
role :web, "50.19.84.170"
role :db,  "50.19.84.170", :primary => true

after "deploy:setup", :fix_perms
after "deploy:update_code", :fix_perms

# ssh_options[:keys] = ["#{ENV['HOME']}/Downloads/important.pem"]

task :fix_perms do
  # sudo "chown apache:webshare -R /var/www/projects"
  # sudo "chmod 666 -R /var/www/projects/shared/log/*"
end

any ideas what i need to change

UPDATE

Here is my entire output

cap deploy
  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote [email protected]:railsdevmatt/fat_free_crm.git master"
/Library/Ruby/Gems/1.8/gems/capistrano-2.6.0/lib/capistrano/recipes/deploy.rb:104: warning: Insecure world writable dir /Users/mattelhotiby in PATH, mode 040777
    command finished in 1061ms
  * executing "git clone -q --depth 1 [email protected]:railsdevmatt/fat_free_crm.git /var/www/projects/releases/20120123144652 && cd /var/www/projects/releases/20120123144652 && git checkout -q -b deploy 65b439e201c2134fc97ee10a4ea66174018d8553 && (echo 65b439e201c2134fc97ee10a4ea66174018d8553 > /var/www/projects/releases/20120123144652/REVISION)"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 1898ms
  * executing `deploy:finalize_update'
  * executing "chmod -R g+w /var/www/projects/releases/20120123144652"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 123ms
  * executing "rm -rf /var/www/projects/releases/20120123144652/log /var/www/projects/releases/20120123144652/public/system /var/www/projects/releases/20120123144652/tmp/pids &&\\\n      mkdir -p /var/www/projects/releases/20120123144652/public &&\\\n      mkdir -p /var/www/projects/releases/20120123144652/tmp &&\\\n      ln -s /var/www/projects/shared/log /var/www/projects/releases/20120123144652/log &&\\\n      ln -s /var/www/projects/shared/system /var/www/projects/releases/20120123144652/public/system &&\\\n      ln -s /var/www/projects/shared/pids /var/www/projects/releases/20120123144652/tmp/pids"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 133ms
  * executing "find /var/www/projects/releases/20120123144652/public/images /var/www/projects/releases/20120123144652/public/stylesheets /var/www/projects/releases/20120123144652/public/javascripts -exec touch -t 201201231446.55 {} ';'; true"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
 ** [out :: 50.19.84.170] find: `/var/www/projects/releases/20120123144652/public/images': No such file or directory
 ** [out :: 50.19.84.170] find: `/var/www/projects/releases/20120123144652/public/stylesheets': No such file or directory
 ** [out :: 50.19.84.170] find: `/var/www/projects/releases/20120123144652/public/javascripts': No such file or directory
    command finished in 111ms
    triggering after callbacks for `deploy:update_code'
  * executing `fix_perms'
  * executing "sudo -p 'sudo password: ' chown apache:webshare -R /var/www/projects"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 136ms
  * executing "sudo -p 'sudo password: ' chmod 666 -R /var/www/projects/shared/log/*"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
 ** [out :: 50.19.84.170] chmod: cannot access `/var/www/projects/shared/log/*': No such file or directory
    command finished in 119ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/projects/releases/20120123144652; true"
    servers: ["50.19.84.170"]
    [50.19.84.170] executing command
    command finished in 145ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' chmod 666 -R /var/www/projects/shared/log/*'" on 50.19.84.170

here is that directory

 ls -la /var/www/projects/shared/
total 20
drwxrwxr-x 5 apache webshare 4096 Jan 23 13:32 .
drwxrwxr-x 5 apache webshare 4096 Jan 20 03:03 ..
drwxrwxr-x 2 apache webshare 4096 Jan 20 03:31 log
drwxrwxr-x 2 apache webshare 4096 Jan 23 13:32 pids
drwxrwxr-x 2 apache webshare 4096 Jan 23 13:32 system

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兔小萌 2025-01-04 11:57:39

因此,从输出中您可以看到:

chmod: cannot access `/var/www/projects/shared/log/*': No such file or directory

Mkdir 那些丢失的目录并确保它们的权限正常。

So, from the ouput you can see:

chmod: cannot access `/var/www/projects/shared/log/*': No such file or directory

Mkdir those missing dirs and make sure their permissions are ok.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文