簡體   English   中英

Rails Capistrano的資產失敗:預編譯SSHKIT

[英]Rails Capistrano fails on assets:precompile SSHKIT

當我將應用程序部署到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

上限文件:

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'

SSH不是您的問題。 根據您提供的日志,資產編譯期間會發生錯誤。

我建議登錄到服務器,將項目克隆到temp目錄,然后手動運行rails assets:precompile 這可能會失敗,並且您必須找出原因。

嘗試將一些交換添加到您的VM,您應該沒問題。 在資產編譯期間,看起來好像它用完了RAM並失敗了。 如果您的小型VM具有1GB RAM,則會發生IT問題。 驗證..在您的VM上安裝htop( apt-get install htop )實用程序,並在部署期間打開。 您應該會看到統計信息。 我曾經也有過一樣的問題。 我的解決方案是在本地PC上編譯並復制它們(您可以在Capistrano中為此做一個任務)

@北歐熊貓和@克拉斯,謝謝您的幫助! 內存不足的確是問題所在,並導致編譯失敗。 我調整了我的Digital Ocean帳戶的大小,現在加倍部署就可以了!

在我這樣做之前(以及仍然使用更輕的服務器)。 我在本地編譯了資產,並按照您的建議分別部署了它們。 這也很好!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM