Rails, Capistrano - Сбой компиляции без обслуживания журнала отладки - PullRequest
0 голосов
/ 07 мая 2018

Я пытаюсь развернуть приложение Rails5 на экземпляре AWS EC2 с помощью Capistrano3.Однако, когда дело доходит до компиляции ресурсов, это завершается неудачно без регистрации каких-либо причин.С чего начать в таком случае?Хотя я установил log_level: :debug на config/deploy/staging.rb, больше информации не было.log/capistrano.log тоже самое.

Я попытался запустить bundle exec rake assets:precompile RAILS_ENV=staging в локальном режиме и успешно.

"log/capistrano.log" 50149L, 2790165C


** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:


 DEBUG [39e6a15a]



 DEBUG [39e6a15a]

 DEBUG [39e6a15a]   warning " > webpack-cli@2.1.3" has incorrect peer dependency "webpack@^4.0.0".

 DEBUG [39e6a15a]

[4/4] Building fresh packages...

success Saved lockfile.



 DEBUG [39e6a15a]

 DEBUG [39e6a15a]   Done in 38.64s.

 DEBUG [39e6a15a]

 DEBUG [39e6a15a]   Webpacker is installed ? ?

 DEBUG [39e6a15a]

 DEBUG [39e6a15a]   Using /home/deploy/apps/neuroweb/releases/20180507061527/config/webpacker.yml file for setting up webpack paths

 DEBUG [39e6a15a]

 DEBUG [39e6a15a]   Compiling…

 DEBUG [39e6a15a]

 DEBUG [39e6a15a]   Compilation failed:

гемов, которые я использую для развертывания:

  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-bundler'
  gem 'capistrano-rbenv'
  gem 'capistrano3-unicorn'

config/deploy/staging.rb

lock "3.10.2"

set :log_level, :debug
set :repo_url,        'xxxxxxxx'
set :application,     'neuroweb'
set :branch, 'staging'
set :keep_releases, 1
set :rbenv_ruby, '2.4.3'

# Don't change these unless you know what you're doing
set :use_sudo,        false
set :deploy_via,      :remote_cache
set :deploy_to,       "/home/deploy/apps/#{fetch(:application)}"


#set :linked_dirs, %w{vendor/bundle}
#set :linked_files, %w{ config/secrets.yml}
append :linked_files, ".env"
set :rbenv_type, :user


set :ssh_options, {
  port: 22,
  forward_agent: true,
  keys: ['~/.ssh/staging.pem'],
}
set :pty, true
server 'xxxx', roles: [:web, :app, :db], primary: true, user: 'ubuntu'
set :keep_releases, 1

set :stage, :staging
set :rails_env, 'staging'
set :unicorn_exec, -> { "unicorn_rails" }
set :unicorn_config_path, -> { File.join(current_path, "config", "unicorn",  "staging.rb") }
set :unicorn_rack_env, 'staging'
set :user,            'ubuntu' #deploy
set :unicorn_pid, "/home/deploy/apps/neuroweb/shared/tmp/pids/unicorn.pid"




namespace :deploy do
  desc "Upload secrets.yml to the shared/config directory."
  task :secrets_yml do
    unless File.exist?('tmp/secrets.yml')
      secrets = { fetch(:stage).to_s =>
        { 'secret_key_base' => SecureRandom.hex(64) } }
      File.open('tmp/secrets.yml', 'w') do |f|
        f.write secrets.to_yaml
      end
    end

    on roles(:app) do
      unless test "[ -f #{shared_path}/config/secrets.yml ]"
        unless test "[ -d #{shared_path}/config ]"
          execute "/bin/mkdir -p #{shared_path}/config/"
        end
        upload! "tmp/secrets.yml", "#{shared_path}/config/secrets.yml"
      end
    end

  end # secrets_yml





  #
  # delayed_job
  #
  task :restart do
    invoke 'unicorn:restart'
    invoke 'delayed_job:restart'
  end
end #deploy


namespace :delayed_job do

  def args
    fetch(:delayed_job_args, "")
  end

  def delayed_job_roles
    fetch(:delayed_job_server_role, :app)
  end

  desc 'Stop the delayed_job process'
  task :stop do
    on roles(delayed_job_roles) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          execute :bundle, :exec, :'bin/delayed_job', :stop
        end
      end
    end
  end

  desc 'Start the delayed_job process'
  task :start do
    on roles(delayed_job_roles) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          execute :bundle, :exec, :'bin/delayed_job', args, :start
        end
      end
    end
  end

  desc 'Restart the delayed_job process'
  task :restart do
    on roles(delayed_job_roles) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          execute :bundle, :exec, :'bin/delayed_job', args, :restart
        end
      end
    end
  end

end


after 'deploy:publishing', 'deploy:restart'

webpacker.yml

default: &default
  source_path: app/javascript
  source_entry_path: packs
  public_output_path: packs
  cache_path: tmp/cache/webpacker

  # Additional paths webpack should lookup modules
  # ['app/assets', 'engine/foo/app/assets']
  resolved_paths: []

  # Reload manifest.json on all requests so we reload latest compiled packs
  cache_manifest: false

  extensions:
    - .jsx
    - .vue
    - .js
    - .sass
    - .scss
    - .css
    - .module.sass
    - .module.scss
    - .module.css
    - .png
    - .svg
    - .gif
    - .jpeg
    - .jpg

development:
  <<: *default
  compile: true

  # Reference: https://webpack.js.org/configuration/dev-server/
  dev_server:
    https: false
    host: localhost
    port: 3035
    public: localhost:3035
    hmr: false
    # Inline should be set to true if using HMR
    inline: true
    overlay: true
    compress: true
    disable_host_check: true
    use_local_ip: false
    quiet: false
    headers:
      'Access-Control-Allow-Origin': '*'
    watch_options:
      ignored: /node_modules/


test:
  <<: *default
  compile: true

  # Compile test packs to a separate directory
  public_output_path: packs-test

production:
  <<: *default
  compile: false
  cache_manifest: true

staging:
  <<: *default
  compile: false
  cache_manifest: true

Ответы [ 2 ]

0 голосов
/ 26 июня 2019

Попробуйте запустить ./bin/webpack прямо на сервере.

У меня была та же проблема, и это показало мне сообщение об ошибке.

0 голосов
/ 15 мая 2019

Это, вероятно, вызвано нехваткой памяти.

Найдите в системном журнале что-то вроде этого, чтобы подтвердить:

Out of memory: Kill process 2736 (node) score 222 or sacrifice child

Решение состоит в том, чтобыобновить до машины (или виртуальной машины), которая имеет больше памяти.

...