我一直在寻找使用capistrano部署应用程序的方法。 我目前在Github上托管一个小型的私有repo和一个本地服务器以尝试部署我的测试。但是我遇到了以下问题和错误信息。
我已经完成以下步骤:
1.在服务器上生成ssh密钥,并成功将其添加到库中的部署密钥中并测试(git@github.com);
2.在客户端上生成ssh密钥,并成功将其添加到库中的部署密钥中;
3.设置了一个私有仓库。 并且有一个名为deployer的帐户具有部署权限;
4.配置了deploy.rb和production rb,以模仿其他模板。
我仍然不能确定为什么会出现这样的错误。
Deploy.rb文件
我已经完成以下步骤:
1.在服务器上生成ssh密钥,并成功将其添加到库中的部署密钥中并测试(git@github.com);
2.在客户端上生成ssh密钥,并成功将其添加到库中的部署密钥中;
3.设置了一个私有仓库。 并且有一个名为deployer的帐户具有部署权限;
4.配置了deploy.rb和production rb,以模仿其他模板。
我仍然不能确定为什么会出现这样的错误。
DEBUG [a5554d3d] Command: /usr/bin/env chmod +x /tmp/App/git-ssh.sh
INFO [a5554d3d] Finished in 0.020 seconds with exit status 0 (successful).
INFO [b1517df1] Running /usr/bin/env git ls-remote --heads git@github.com:aceofw
ings/App.git as deploy@192.168.1.84
DEBUG [b1517df1] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/App/git-ssh
.sh /usr/bin/env git ls-remote --heads git@github.com:aceofwings/App.git )
DEBUG [b1517df1] Permission denied (publickey).
DEBUG [b1517df1] fatal: Could not read from remote repository.
DEBUG [b1517df1]
DEBUG [b1517df1] Please make sure you have the correct access rights
DEBUG [b1517df1] and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@192.168.1.84:
git exit status: 128
git stdout: Nothing written
git stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
SSHKit::Command::Failed: git exit status: 128
git stdout: Nothing written
Deploy.rb文件
###############Deploy.rb##################
# config valid only for current version of Capistrano
lock '3.4.0'
set :repo_url, 'git@github.com:aceofwings/App.git'
set :application, 'App'
set :user, 'deploy'
#set :pty, true
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
Production.rb
server '192.168.1.84', user: 'deploy', roles: %w{app db web}
#set :stage, :production
role :app, %w{deploy@192.168.1.84}
role :web, %w{deploy@192.168.1.84}
role :db, %w{deploy@192.168.1.84}
set :ssh_options, {
forward_agent: false,
auth_methods: %w(password),
password: 'Deploy4Real',
user: 'deploy'
}
deploy
用户上运行git ls-remote --heads git@github.com:aceofwings/App.git
,这个怎么样? - smallbuttonINFO [b1517df1] Running /usr/bin/env git ls-remote --heads git@github.com:aceofwings/RotairApp.git
。是应用程序从RotairApp重命名为App或者其他什么原因吗? - smallbutton