【发布时间】:2018-07-23 06:40:45
【问题描述】:
我有一个仅适用于 sqlite 的示例 node.js 应用程序。
我想在 AWS ElasticBeanstalk 上进行“概念验证”,而无需重写 node.js 应用程序以使用受支持的数据库
为了启动 node.js 应用程序,我必须首先通过执行 node db.js 为 sqlite 数据库播种。
如何在 EBS 实例上执行此节点命令?
我尝试向 .ebextensions 添加命令
.ebextensions/foo.config
commands:
1_seed_db:
command: "PATH=$PATH:`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin node db.js"
返回错误:
错误:找不到模块'/var/app/current/db.js;'
我怀疑 /var/app/current 目录还不存在,所以我也尝试修改 NodeCommand 使其执行自定义命令 node db.js; npm start as documented here:
.ebextensions/node.config
option_settings:
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeCommand
value: node db.js; npm start
如何让 Elastic beanstalk 在启动节点进程之前执行node db.js?
【问题讨论】:
标签: javascript node.js sqlite amazon-web-services amazon-elastic-beanstalk