Запуск rake deploy: миграция после развертывания capistrano не находит миграций - PullRequest
0 голосов
/ 10 июля 2019

Я развертываю приложение rails с capistrano, развертывание выполняется правильно.

Запуск db: мигрировать вручную или также развернуть: миграция через capistrano не принимает отложенные миграции. Пользователь развертывания является суперпользователем в postgresql "basedremote_development"

deploy.rb

server '173.XXX.XXX.XXX', port: 22, roles: [:web, :app, :resque_worker, :resque_scheduler, :db], primary: true

set :repo_url,        'git@bitbucket.org:sXXX'
set :application,     'basedremote'
set :user,            'deploy'
set :puma_threads,    [4, 16]
set :puma_workers,    0
set :migration_role, :deploy

# Don't change these unless you know what you're doing
set :pty,             true
set :use_sudo,        false
set :stage,           :production
set :deploy_via,      :remote_cache
set :deploy_to,       "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state,      "#{shared_path}/tmp/pids/puma.state"
set :puma_pid,        "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log,  "#{release_path}/log/puma.access.log"
set :ssh_options,     { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true  # Change to false when not using ActiveRecord

## Defaults:
# set :scm,           :git
# set :branch,        :master
# set :format,        :pretty
# set :log_level,     :debug
# set :keep_releases, 5


## Linked Files & Directories (Default None):
set :linked_files, fetch(:linked_files, []).push("config/master.key")
# set :linked_dirs,  %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
#set :linked_dirs,  %w{tmp log public/system db config}
set :linked_dirs,  %w{db tmp log public/system}

namespace :puma do
  desc 'Create Directories for Puma Pids and Socket'
  task :make_dirs do
    on roles(:app) do
      execute "mkdir #{shared_path}/tmp/sockets -p"
      execute "mkdir #{shared_path}/tmp/pids -p"
    end
  end

  before :start, :make_dirs
end

namespace :deploy do
  desc "Make sure local git is in sync with remote."
  task :check_revision do
    on roles(:app) do
      unless `git rev-parse HEAD` == `git rev-parse origin/master`
        puts "WARNING: HEAD is not the same as origin/master"
        puts "Run `git push` to sync changes."
        exit
      end
    end
  end

  desc 'Initial Deploy'
  task :initial do
    on roles(:app) do
      before 'deploy:restart', 'puma:start'
      invoke 'deploy'
    end
  end

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      invoke 'puma:restart'
    end
  end

  # Specify the server that Resque will be deployed on. If you are using Cap v3
  # and have multiple stages with different Resque requirements for each, then
  # these __must__ be set inside of the applicable config/deploy/... stage files
  # instead of config/deploy.rb:
  #role :resque_worker, "173.230.XXX.XXX"
  #role :resque_scheduler, "173.230.XXX.XXX"


  set :workers, { "scraper" => 1 }
  set :migration_role, :app


  # We default to storing PID files in a tmp/pids folder in your shared path, but
  # you can customize it here (make sure to use a full path). The path will be
  # created before starting workers if it doesn't already exist.
  # set :resque_pid_path, -> { File.join(shared_path, 'tmp', 'pids') }

  # Uncomment this line if your workers need access to the Rails environment:
  #set :resque_environment_task, true


  before :starting,     :check_revision
  after  :finishing,    :compile_assets
  after  :finishing,    :cleanup
  after  :finishing,    :restart
  after "deploy:restart", "resque:restart"
  after "deploy:updated", "deploy:migrating"

end

# ps aux | grep puma    # Get puma pid
# kill -s SIGUSR2 pid   # Restart puma
# kill -s SIGTERM pid   # Stop puma

database.yml

default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see Rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: basedremote_development
  pool: 5
  username: basedremote
  password: *******
  host: 127.0.0.1


test:
  <<: *default
  database: basedremote_test



production:
  <<: *default
  database: basedremote_production
  username: deploy
  password: m******
  host: localhost 

Папка db является символической ссылкой, но миграции не могут быть найдены, в чем причина?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...