您如何在AWS Elastic Beanstalk应用程序上调用db:seed? [英] How do you call db:seed on AWS Elastic Beanstalk apps?
本文介绍了您如何在AWS Elastic Beanstalk应用程序上调用db:seed?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道您可以在每次部署中运行任务,但是我只想引导数据库一次.
I know that you can run tasks as part of each deploy, but I only want to bootstrap the database once.
推荐答案
克里斯蒂安的答案很接近,但您还应该添加:
Kristian's answer is close, but you should also add:
container_commands:
seeddb:
command: 'export HOME=/root; rake db:seed'
leader_only: true
因此,仅从1个EC2实例播种该数据库,而不是同时从所有它们播种.根据您的EB部署/版本,可能需要或可能不需要export HOME
.
So that the DB is only seeded from 1 EC2 instance, rather than all of them at the same time. Depending on your EB deployment/version, the export HOME
may or may not be needed.
这篇关于您如何在AWS Elastic Beanstalk应用程序上调用db:seed?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文