我正在使用邁納部署我的應用程序。我指定了我想部署應用程序的env(staging/production)。如何從邁納部署腳本運行定製耙任務
mina deploy on=staging --verbose
我已經保存在deploy.rb應用ENV作爲
app_env = ENV['on'] || 'staging'
我有一個耙的任務,需要生產數據庫的備份。到目前爲止,我在控制檯上明確執行了這個rake任務,因爲我想在每個生產部署上運行該任務。我該怎麼做?
我正在使用邁納部署我的應用程序。我指定了我想部署應用程序的env(staging/production)。如何從邁納部署腳本運行定製耙任務
mina deploy on=staging --verbose
我已經保存在deploy.rb應用ENV作爲
app_env = ENV['on'] || 'staging'
我有一個耙的任務,需要生產數據庫的備份。到目前爲止,我在控制檯上明確執行了這個rake任務,因爲我想在每個生產部署上運行該任務。我該怎麼做?
小米對此有特殊的語法。距離Mina控制檯的幫助頁面:
Server tasks:
...
mina rails[arguments] # Execute a Rails command in the current deploy
mina rake[arguments] # Execute a Rake command in the current deploy
mina run[command] # Runs a command in the server
...
因此,從命令行:
$ mina 'rake[deploy:backup_db]'
或者米娜定義任務部署配置文件(config/deploy.rb
):
task :backup_db do
invoke :'rake[deploy:backup_db]'
end
讓它工作。更改如下:
...
app_env = ENV['on'] || 'staging'
...
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke 'production_backup' if app_env == 'production'
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:assets_precompile'
to :launch do
invoke 'application:restart'
end
end
end
task :production_backup do
queue "cd #{deploy_to}/current ; bundle exec rake deploy:backup_db"
end