Ограничение ошибок развертывания при компиляции ресурсов, но может выполняться отдельно - PullRequest
0 голосов
/ 01 мая 2020

Я начинаю новый проект, и у меня возникла проблема с Capistrano для развертываний. Я делаю cap production deploy Я получаю сообщение об ошибке, что там secret_key_base отсутствует.

Я на Rails 6, и у меня есть секретные файлы для каждой среды. Я могу подтвердить, что он работает, введя cd в папку проекта и запустив RAILS_ENV=production rails c и проверив Rails.application.credentials.secret_key_base. После сбоя развертывания я также могу выполнить `cap production deploy: compile_assets без сбоев.

Я скопировал файлы конфигурации Capistrano со своего веб-сайта, работающего на том же сервере, и реорганизовал его.

Любая помощь на это высоко ценится. Заранее спасибо.

Ошибка

Это при работе cap production deploy. cap production deploy:compile_assets работает отлично -_-.

Полный вывод можно найти здесь

00:21 deploy:assets:precompile
      01 /usr/share/rvm/bin/rvm 2.5.1@wonder_of_asia do bundle exec rake assets:precompile
      01 rake aborted!
      01 ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit`
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/application.rb:580:in `validate_secret_key_base'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/application.rb:423:in `secret_key_base'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/devise-4.7.1/lib/devise/secret_key_finder.rb:24:in `key_exists?'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/devise-4.7.1/lib/devise/secret_key_finder.rb:16:in `find'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/devise-4.7.1/lib/devise/rails.rb:37:in `block in <class:Engine>'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `instance_exec'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `run'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/initializable.rb:60:in `run_initializers'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/application.rb:363:in `initialize!'
      01 /var/www/wonderof.asia/releases/20200501142709/config/environment.rb:5:in `<top (required)>'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in …
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in …
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `r…
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in …
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in …
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in req…
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_depende…
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/application.rb:339:in `require_environment!'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/railties-6.0.2.2/lib/rails/application.rb:515:in `block in run_tasks_blocks'
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in …
      01 /var/www/wonderof.asia/shared/bundle/ruby/2.5.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
      01 /usr/share/rvm/rubies/ruby-2.5.1/bin/bundle:30:in `block in <main>'
      01 /usr/share/rvm/rubies/ruby-2.5.1/bin/bundle:22:in `<main>'
      01 /usr/share/rvm/gems/ruby-2.5.1@global/bin/ruby_executable_hooks:24:in `eval'
      01 /usr/share/rvm/gems/ruby-2.5.1@global/bin/ruby_executable_hooks:24:in `<main>'
      01 Tasks: TOP => environment
      01 (See full trace by running task with --trace)

Отдельно работает компиляция ресурсов

Что абсурдно cap production deploy:asset_compile работает.

ziyan@ziyan-hp  ~/Work/JDeen/wonder_of_asia   master  cap production deploy:compile_assets
rvm 1.29.10 (manual) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
ruby-2.5.1
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
00:00 deploy:assets:precompile
      01 /usr/share/rvm/bin/rvm 2.5.1@wonder_of_asia do bundle exec rake assets:precompile
      01 yarn install v1.12.3
      01 [1/4] Resolving packages...
      01 [2/4] Fetching packages...
      01 info fsevents@1.2.12: The platform "linux" is incompatible with this module.
      01 info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
      01 [3/4] Linking dependencies...
      01 warning " > webpack-dev-server@3.10.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
      01 warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0".
      01 [4/4] Building fresh packages...
      01 Done in 8.78s.
      01 yarn install v1.12.3
      01 [1/4] Resolving packages...
      01 [2/4] Fetching packages...
      01 info fsevents@1.2.12: The platform "linux" is incompatible with this module.
      01 info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
      01 [3/4] Linking dependencies...
      01 warning " > webpack-dev-server@3.10.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
      01 warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0".
      01 [4/4] Building fresh packages...
      01 Done in 8.10s.
      01 Everything's up-to-date. Nothing to do
    ✔ 01 root@wonderof.asia 22.812s
00:22 deploy:assets:backup_manifest
      01 mkdir -p /var/www/wonderof.asia/current/assets_manifest_backup
    ✔ 01 root@wonderof.asia 0.205s
      02 cp /var/www/wonderof.asia/current/public/assets/.sprockets-manifest-73b1cea3ed65a141eef6217662fafc93.json /var/www/wonderof.asia/current/assets_manifest_backup
    ✔ 02 root@wonderof.asia 0.133s

Файлы конфигурации

deloy.rb. Эти конфигурационные файлы взяты из другого проекта с более старой версией Capistrano. Я проверил различия, и они, кажется, похожи.

# config valid for current version and patch releases of Capistrano
lock '~> 3.13.0'

set :application, 'jdeencom'
set :repo_url, 'git@github.com:jdeen/wonder-of-asia.git'

ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp

# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, "/var/www/wonderof.asia"

# Default value for :format is :airbrussh.
# set :format, :airbrussh

# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
append :linked_files,
  'config/database.yml',
  'config/master.key'
  'config/credentials/production.key'


# Default value for linked_dirs is []
append :linked_dirs,
       'log',
       'tmp/pids',
       'tmp/cache',
       'tmp/sockets',
       'public/system',
       'public/uploads'

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for local_user is ENV['USER']
set :local_user, 'root'

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

# Uncomment the following to require manually verifying the host key before first deploy.
# set :ssh_options, verify_host_key: :secure

set :rvm_type, :user
set :rvm_ruby_version, '2.5.1@wonder_of_asia'

И config/deploy/production.rb

server 'wonderof.asia',
  user: 'root',
  roles: %w[web app],
  ssh_options: {
    forward_agent: true
  }

set :rvm_custom_path, '/usr/share/rvm'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...