为什么 cap deploy 会出现问题,但 cap deploy:cold 却可以正常工作?

发布于 2025-01-02 14:10:06 字数 1334 浏览 4 评论 0原文

我正在将网站上传到服务器。当我使用 cap deploy:cold 时,我可以成功上传网站,并且网站工作正常。但是,我正在提前计划,并希望有一种方法可以更新网站上的代码/在数据库上运行迁移,而不会丢失数据库中的所有数据,这在我使用 cap deploy:cold 时似乎会发生。 。

我的 deploy.rb 文件包含:

require "bundler/capistrano"
#require "csv"

set :application, "my domain"
set :user, "my username"

set :repository, "."
set :deploy_via, :copy
set :deploy_to, "/home/users/#{user}/html/#{application}"
set :ssh_options, { :user => user, :port => 50022 }
set :use_sudo, false

set :scm, :none

role :web, application
role :app, application
role :db, application, :primary => true

namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch
    #{File.join(current_path,'tmp','restart.txt')}"
end
end

此代码是我们的托管提供商建议我使用的代码。正如我提到的,cap deploy:cold 成功运行,并且站点按预期运行。当我运行 cap deploy 时,我收到错误 - 我们很抱歉,但出了点问题。我们已收到有关此问题的通知,很快就会查看它。我注意到 cap deploy:cold 调用的进程是 deploy:update、<代码>部署:迁移和<代码>部署:启动。为了缩小问题范围,我尝试单独运行 deploy:update ,它不会报告任何错误,但在加载站点时会产生相同的错误消息。运行 cap deploy:start 并不能解决问题。

有人能够阐明这里可能发生的事情吗?您还可以确认我应该如何处理网站代码和网站代码吗?将来运行数据库迁移,而不会丢失数据库中当前的数据?
`

I am in the process of uploading a website to a server. I can successfully upload the site when i use cap deploy:cold and the site works fine. However, i am planning ahead and want a means of updating the code on the website / running migrations on the db, without losing all the data in the database which seems to happen when i use cap deploy:cold.

My deploy.rb file contains:

require "bundler/capistrano"
#require "csv"

set :application, "my domain"
set :user, "my username"

set :repository, "."
set :deploy_via, :copy
set :deploy_to, "/home/users/#{user}/html/#{application}"
set :ssh_options, { :user => user, :port => 50022 }
set :use_sudo, false

set :scm, :none

role :web, application
role :app, application
role :db, application, :primary => true

namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch
    #{File.join(current_path,'tmp','restart.txt')}"
end
end

This code is what i was advised to use by our hosting provider. As i mentioned, cap deploy:cold works successfully and the site works as expected. When I run cap deploy i get the error - We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly. I noted that the processes called by cap deploy:cold are deploy:update, deploy:migrate and deploy:start. To try to narrow down the problem, i tried running deploy:update on its own, it works with no errors being reported but produces the same error message when i load the site. Running cap deploy:start doesn't solve the problem.

Is anybody able to shed any light on what might be happening here? Can you also confirm how I should go about uodating the website code & running database migrations in the future, without losing the data currently in the databases?
`

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

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

发布评论

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

评论(1

酒儿 2025-01-09 14:10:06

如果我没看错的话,您需要一个命令来更新您的代码并执行所有待处理的迁移。幸运的是,cap deploy:migrations 就是这么做的。 (不要与仅迁移的 cap deploy:migrate 混淆。

如果您想在仅使用 cap deploy 时运行迁移,您可以添加:

before 'deploy:symlink', 'deploy:migrate' #use hook 'deploy:create_symlink' if using 2.10.0

到您的配方中。

If I'm reading this right, you want one command to update your code and do all pending migrations. Luckily, cap deploy:migrations does just that. (not to be confused with cap deploy:migrate which only migrates.

If you want to run migrations while only using cap deploy, you could add:

before 'deploy:symlink', 'deploy:migrate' #use hook 'deploy:create_symlink' if using 2.10.0

To your recipe.

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