Jadi aplikasi ini berfungsi dengan baik ketika saya menyebarkannya ke Heroku

Saya mencoba menyebarkan ini ke VM (tetesan ubuntu biasa di lautan digital)

Telah mengatur Capistrano seperti yang diharapkan. Saya tidak dapat mengetahui dari mana kesalahan ini mungkin berasal

SSHKit::Runner::ExecuteError: Exception while executing as deploy@<IP ADDRRESS>: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written

Log penyebaran Capistrano adalah sebagai berikut:

00:21 deploy:assets:precompile
      01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
#<Thread:0x00007ff9d8ba40f8 /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
    13: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
    12: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:31:in `run'
    11: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
    10: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/capistrano-rails-1.6.1/lib/capistrano/tasks/assets.rake:67:in `block (4 levels) in <top (required)>'
     9: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:92:in `within'
     8: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/capistrano-rails-1.6.1/lib/capistrano/tasks/assets.rake:68:in `block (5 levels) in <top (required)>'
     7: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:100:in `with'
     6: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/capistrano-rails-1.6.1/lib/capistrano/tasks/assets.rake:69:in `block (6 levels) in <top (required)>'
     5: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:80:in `execute'
     4: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
     3: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in `tap'
     2: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
     1: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/backends/netssh.rb:170:in `execute_command'
/Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/command.rb:97:in `exit_status=': rake exit status: 1 (SSHKit::Command::Failed)
rake stdout: Nothing written
rake stderr: Nothing written
    1: from /Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/josh.kurien/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/sshkit-1.21.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as deploy@<IP ADDRRESS>: rake exit status: 1 (SSHKit::Runner::ExecuteError)
rake stdout: Nothing written
rake stderr: Nothing written
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@<IP ADDRRESS>: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written


Caused by:
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy@<IP ADDRRESS>: rake exit status: 1
rake stdout: Nothing written
rake stderr: Nothing written


** DEPLOY FAILED

Mencoba menjalankan perintah terakhir secara manual (seperti yang ditunjukkan dalam log debug)

cd /home/deploy/mark_antony/releases/20201201034511 && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.7.1" RAILS_ENV="production" RAILS_GROUPS="" ; $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )

Dan ini bekerja dengan sangat baik. Ketika saya mencoba menjalankan build ini di server secara manual, itu juga berfungsi

Butuh bantuan tolong

Ini deploy.rb saya:

# config valid for current version and patch releases of Capistrano
lock "~> 3.14.1"

set :application, "mark_antony"
set :repo_url, "git@gitlab.com:browneinstitute/mark.git"

# Default branch is :master
set :deploy_to, "/home/deploy/#{fetch :application}"

append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'

set :keep_releases, 5

append :linked_files, "config/master.key"

Catatan Samping: Saya secara manual membuat symlink current baru ke direktori rilis yang dibuat dengan cara ini untuk melihat apakah nginx dapat melayani halaman web. Dan mampu

0
Josh Kurien 1 Desember 2020, 07:03

3 jawaban

Jawaban Terbaik

Jadi saya pikir ini selalu gagal pada aset precompile dan jawabannya di sini: https://stackoverflow.com/a/61210930/2358326

Membantu menyelesaikan masalah, kecuali saya harus menambahkan nilai yang sedikit berbeda untuk jalurnya

# add in deploy.rb

set :default_env, {
    PATH: '$HOME/.nvm/versions/node/v14.15.1/bin/:$PATH',
    NODE_ENVIRONMENT: 'production'
}

Ini karena menjalankan $ which yarn di VM mengembalikan yang berikut:

/home/deploy/.nvm/versions/node/v14.15.1/bin/yarn
1
Josh Kurien 5 Februari 2021, 16:04

Mungkin Anda perlu menambahkan ssh Anda lagi, coba ini ssh-add, di konsol Anda, lalu coba terapkan lagi.

0
certilremy 2 Desember 2020, 18:55

Masalahnya tampaknya Anda kehilangan beberapa konfigurasi kunci di deploy.rb yang tanpanya Anda tidak dapat terhubung ke droplet Anda.

# config valid for current version and patch releases of Capistrano
lock "~> 3.14.1"

server 'YOUR_DROPLET_IP',
roles: [:web, :app, :db],

set :user,  'deploy'
set :application, "mark_antony"
set :repo_url, "git@gitlab.com:browneinstitute/mark.git"

# Default branch is :master
set :deploy_to, "/home/deploy/#{fetch :application}"

append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads'

set :keep_releases, 5
# This might not be needed. If needed make sure to provide the correct path to your ssh key
set :ssh_options,     {
                        forward_agent: true,
                        user: fetch(:user),
                        keys: %w(~/.ssh/id_rsa)
                      } 

append :linked_files, "config/master.key"
0
Daniel Sindrestean 9 Desember 2020, 22:18