gpt4 book ai didi

ruby-on-rails - Rails 4 + Capistrano 3 - 从本地仓库部署到生产服务器

转载 作者:太空狗 更新时间:2023-10-29 14:44:45 25 4
gpt4 key购买 nike

我正在使用 Windows 10 和 Cygwin,我正在设置 Capistrano 3 以部署到我的生产环境。我相信我已经正确设置了所有内容,但我不知道如何将我的本地存储库推送到我的生产服务器。我在 GitHub 或其他此类网站上没有我的 repo 协议(protocol),我想将其保留在本地。我在运行 cap production deploy 时收到以下错误消息。

SSHKit::Runner::ExecuteError: Exception while executing as myappuser@myappname.website.com: git exit status: 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.

SSHKit::Command::Failed: git exit status: 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.

Tasks: TOP => git:check (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as myappuser@myappname.website.com: git exit status : 128 git stdout: Nothing written git stderr: fatal: No remote configured to list refs from.

这是我的config\deploy.rb 文件:

# config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'myappname
set :deploy_user, 'myappuser'
set :repo_url, "file:///C:/Users/me/Documents/repo/myappname.git"

# setup rvm.
set :rbenv_type, :user
set :rbenv_ruby, '2.1.5-p273'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}

set :assets_roles, [:app]

# Default value for :scm is :git
set :scm, :git

# Default value for :linked_files is []
set :linked_files, %w{config/database.yml config/application.yml}

# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for keep_releases is 5
set :keep_releases, 5

# which config files should be copied by deploy:setup_config
# see documentation in lib/capistrano/tasks/setup_config.cap
# for details of operations
set(:config_files, %w(
nginx.conf
application.yml
database.yml
unicorn.rb
unicorn_init.sh
))

# which config files should be made executable after copying
# by deploy:setup_config
set(:executable_config_files, %w(
unicorn_init.sh
))

# files which need to be symlinked to other parts of the
# filesystem. For example nginx virtualhosts, log rotation
# init scripts etc. The full_app_name variable isn't
# available at this point so we use a custom template {{}}
# tag and then add it at run time.
set(:symlinks, [
{
source: "nginx.conf",
link: "/etc/nginx/sites-enabled/{{full_app_name}}"
},
{
source: "unicorn_init.sh",
link: "/etc/init.d/unicorn_{{full_app_name}}"
},
{
source: "log_rotation",
link: "/etc/logrotate.d/{{full_app_name}}"
}
])

namespace :deploy do
# compile assets locally then rsync
after :finishing, 'deploy:cleanup'
end

我找到的所有答案都没有解决方案或针对 Capistrano 2,所以我想知道选项是否已更改。任何帮助将不胜感激!

编辑

我已经取得了一些进展,但它仍然没有读取我的本地存储库。这是错误消息:

SSHKit::Command::Failed: git exit status: 128 git stdout: Nothing written git stderr: fatal: '/C:/Users/me/Documents/repo/myappname.git' does not appear to be a git repository fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

我已经为我的存储库尝试了所有不同的路径组合。我的 git 存储库位于以下路径:C:/Users/me/Documents/repo/myappname。是否有特定的方式来引用我的本地存储库?

最佳答案

不幸的是,这不是 Capistrano 设计的工作方式。 Capistrano 所做的基本假设是您的项目驻留在服务器可以访问的存储库中(几乎总是这是托管在 Bitbucket 或 GitHub 上的 Git 存储库)。

Capistrano 通过在服务器上运行 git 命令 来 pull 您的源代码。服务器无法查看您的本地存储库,这就是它不起作用的原因。

有一些插件试图改变 Capistrano 的行为以允许您正在寻找的push 样式部署。在 GitHub 上搜索“capistrano copy”并尝试一下。这可能是您正在寻找的:

https://github.com/ydkn/capistrano-git-copy

关于ruby-on-rails - Rails 4 + Capistrano 3 - 从本地仓库部署到生产服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34967932/

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