Я пытаюсь использовать рецепт Capistrano для развертывания приложения Ruby on Rails на CentOS Linux release 7.4.1708 (Core)
.
Сервер CentOS имеетпеременная окружения как VERSION
, которая не позволяет Capistrano запускать задачу rake db:migrate
.
В deploy.rb
я создал ловушку перед unset VERSION
следующим образом, но это не работает.
namespace :deploy do
before :migrating, :get_version_info
task :get_version_info do
on roles(:app) do
set :default_env, { VERSION: nil }
execute("echo $VERSION")
execute("unset VERSION")
execute("echo $VERSION")
end
end
end
Я получаю следующую ошибку:
01:13 deploy:migrate
[deploy:migrate] Run `rake db:migrate`
01:13 deploy:get_version_info
01 echo $VERSION
01 7
✔ 01 ssh_user@remote_server_address 0.966s
02 unset VERSION
✔ 02 ssh_user@remote_server_address 0.960s
01 7
✔ 01 ssh_user@remote_server_address 0.967s
01:17 deploy:migrating
01 bundle exec rake db:migrate
01 /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/net-ldap-0.5.1/lib/net/ber/core_ext.rb:38: warning: constant ::Bignum is deprecated
01 /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/net-ldap-0.5.1/lib/net/ber/core_ext.rb:45: warning: constant ::Fixnum is deprecated
01 The PGconn, PGresult, and PGError constants are deprecated, and will be
01 removed as of version 1.0.
01
01 You should use PG::Connection, PG::Result, and PG::Error instead, respectively.
01
01 Called from /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
01 rake aborted!
01 ActiveRecord::UnknownMigrationVersionError:
01
01 No migration with version number 7
01
01 /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:952:in `migrate'
01 /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:830:in `down'
01 /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:805:in `migrate'
01 /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
01 /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
01 /opt/apps/my_app/shared/bundle/ruby/2.4.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
01 /usr/bin/bundle:22:in `load'
01 /usr/bin/bundle:22:in `<main>'
01 Tasks: TOP => db:migrate
01 (See full trace by running task with --trace)
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as
ssh_user@remote_server_address: Exception while executing as
ssh_user@remote_server_address: rake exit status: 1
Любая помощь или обходной путь будут высоко оценены.
Информация об инструментах
Версия Capistrano: 3.10.2 (версия для рейка: 12.3.1)
ruby 2.4.1p111 (2017-Редакция 03-22 58053)
Рельсы 4.2.8