我無法檢測到這是服務器實例啓動後第一次嘗試部署。我只需要第一次運行命令rake db:seed
來設置數據庫中的默認用戶和其他細節。我不知道這是否可能。Engineyard部署:如何在deployhooks中檢測到它首次嘗試執行'rake db:seed'
有人可以幫我請
我無法檢測到這是服務器實例啓動後第一次嘗試部署。我只需要第一次運行命令rake db:seed
來設置數據庫中的默認用戶和其他細節。我不知道這是否可能。Engineyard部署:如何在deployhooks中檢測到它首次嘗試執行'rake db:seed'
有人可以幫我請
,找出最好的辦法是通過發送--extra-deploy-hook-options
運行的部署命令,並在after_migrate.rb
如果config[:initial]
存在或不檢查時。該命令會是什麼樣子
ey deploy -e myapp_staging --config=initial:true
after_migrate.rb鉤子將是這樣的:
on_app_servers do
if config[:initial] == 'true'
$stderr.puts "Seeding the data"
run "cd #{config.release_path}"
run "bundle exec rake db:seed"
else
$stderr.puts "Skipping the Seeding process"
end
end
欲瞭解更多信息ey help deploy
有幾種方法可以做到這一點。
最簡單的方法是在db/seeds.rb
中執行此操作,並查詢數據是否已存在,否則在運行時將被覆蓋。
如果已完成,您可以在部署鉤子中運行rake db:seed
。 您可以在這裏部署掛鉤找到文檔:https://support.cloud.engineyard.com/hc/en-us/articles/205407008-Use-Ruby-Deploy-Hooks
其實我知道直播。我想知道如果我能檢測如果這個部署嘗試是第一個部署,那麼在部署鉤子內部,這樣只有在需要#bastilian時纔會進行播種 – illusionist