当我将应用程序部署到Digital Ocean(Ubuntu 18.04)时。部署过程将使deploy:assets:precompile失败。它没有提供特定的错误。我浏览了许多类似的案例,但是它们不能解决问题。
我检查了我的ssh设置,它们似乎是正确的。 ssh_config中的#AllowAgentForwarding设置设置为yes(本地和远程)。 ssh-add -l alsi返回正确的ssh代理
有什么想法吗?感谢您的帮助!
以下是我的错误输出:
00:09 deploy:assets:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 I, [2019-07-11T10:37:53.282876 #17762] INFO -- sentry: ** [Raven] Raven 2.9.0 ready to catch errors
01 yarn install v1.16.0
01 [1/4] Resolving packages...
01 [2/4] Fetching packages...
01 info fsevents@1.2.9: The platform "linux" is incompatible with this module.
01 info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
01 info fsevents@2.0.7: The platform "linux" is incompatible with this module.
01 info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
01 [3/4] Linking dependencies...
01 [4/4] Building fresh packages...
01 Done in 22.00s.
01 Compiling…
01 Compilation failed:
01
01
#<Thread:0x00007fbb8d3ba470@/Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
13: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
12: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/abstract.rb:31:in `run'
11: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
10: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/capistrano-rails-1.4.0/lib/capistrano/tasks/assets.rake:67:in `block (4 levels) in <top (required)>'
9: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/abstract.rb:92:in `within'
8: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/capistrano-rails-1.4.0/lib/capistrano/tasks/assets.rake:68:in `block (5 levels) in <top (required)>'
7: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/abstract.rb:100:in `with'
6: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/capistrano-rails-1.4.0/lib/capistrano/tasks/assets.rake:69:in `block (6 levels) in <top (required)>'
5: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/abstract.rb:80:in `execute'
4: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
3: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/abstract.rb:148:in `tap'
2: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
1: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/backends/netssh.rb:169:in `execute_command'
/Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/command.rb:97:in `exit_status=': rake exit status: 1 (SSHKit::Command::Failed)
rake stdout: I, [2019-07-11T10:37:53.282876 #17762] INFO -- sentry: ** [Raven] Raven 2.9.0 ready to catch errors
yarn install v1.16.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.0.7: The platform "linux" is incompatible with this module.
info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 22.00s.
Compiling…
Compilation failed:
rake stderr: Nothing written
1: from /Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/sebastiaan/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.19.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as deploy@134.209.201.210: rake exit status: 1 (SSHKit::Runner::ExecuteError)
rake stdout: I, [2019-07-11T11:12:13.618508 #20267] INFO -- sentry: ** [Raven] Raven 2.9.0 ready to catch errors
yarn install v1.16.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.0.7: The platform "linux" is incompatible with this module.
info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 22.95s.
Compiling…
Compilation failed:
rake stderr: Nothing written
Capfile:
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require "capistrano/rbenv"
require "capistrano/rails"
require "capistrano/passenger"
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
set :rbenv_type, :user
set :rbenv_ruby, '2.6.3'
Deploy.rb
lock "~> 3.11.0"
set :application, "youba"
set :repo_url, "git@bitbucket.org:pspoppen/youba.git"
set :deploy_to, "/home/deploy/#{fetch :application}"
append :linked_files, 'config/database.yml'
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'
set :keep_releases, 10
set :ssh_options, { forward_agent: true }
宝石文件(相关宝石)
gem 'capistrano', '~> 3.11'
gem 'capistrano-rails', '~> 1.4'
gem 'capistrano-passenger', '~> 0.2.0'
gem 'capistrano-rbenv', '~> 2.1', '>= 2.1.4'
gem 'webpacker', '~> 4.x'
答案 0 :(得分:0)
SSH不是您的问题。根据您提供的日志,资产编译期间会发生错误。
我建议登录到服务器,将项目克隆到临时目录,然后手动运行rails assets:precompile
。这可能会失败,并且您必须找出原因。
答案 1 :(得分:0)
尝试将一些交换添加到您的VM,您应该没问题。在资产编译期间,看起来好像它用完了RAM并失败了。如果您的小型VM具有1GB RAM,则会发生IT问题。要验证该..在您的VM上安装htop(if (conditionThatMeansStop)
{
System.Diagnostics.Debugger.Break();
}
)实用程序,并在部署期间打开它。您应该会看到统计信息。我曾经也有过一样的问题。我的解决方案是在本地PC上进行编译并复制(您可以在Capistrano中为此做一个任务)
答案 2 :(得分:0)
@北欧熊猫和@克拉斯,谢谢您的帮助!内存不足的确是问题所在,并导致编译失败。我调整了我的Digital Ocean帐户的大小,现在加倍部署就可以了!
在执行此操作之前(并且仍然在较轻的服务器上)。我在本地编译了资产,并按照您的建议分别部署了它们。这也很好!