我尝试设置Heroku Button,我的应用需要几个post post脚本。不知道怎么把它放在每个旁边。
这是我的app.json
{
"name": "App on Heroku",
"description": "The App deployable to Heroku.",
"keywords": [
"App",
"Heroku"
],
"repository": "https://github.com/myaccount/myapp",
"logo": "http://node-js-sample.herokuapp.com/node.svg",
"addons": [
"heroku-postgresql",
"postmark"
],
"scripts": {
"postdeploy": [
"bundle exec rake db:migrate",
"bundle exec rake db:seed",
"bundle exec my_sample:load"
]
}
}
此处的错误消息
运行脚本&比例dynos
Postdeploy退出代码不是0
bash: ((: bundle exec rake db:migrate,bundle exec rake db:seed,bundle exec my_sample:load: syntax error in expression (error token is "exec rake db:migrate,bundle exec rake db:seed,bundle exec my_sample:load")
答案 0 :(得分:2)
这对我有用:
myscript.sh
的bash / sh脚本(通常,这应该是您的根目录)。chmod +x myscript.sh
。我的 app.json 文件:
{
...
"scripts": {
"postdeploy": "./myscript.sh"
}
}
myscript.sh 文件:
#!/bin/sh
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec my_sample:load
答案 1 :(得分:0)
应该能够做到这一点(dokku示例,但heroku也是如此)
{
"scripts": {
"dokku": {
"predeploy": "bundle exec rake db:migrate && bundle exec rake some:task"
}
}
}
答案 2 :(得分:0)
我发现此问题在搜索其他问题,但认为此文档相关 -https://devcenter.heroku.com/articles/release-phase#review-apps-and-the-postdeploy-script
要应用该文档并回答您的问题:
通过使用以下命令在Heroku Procfile中运行db:migrate
命令,将架构设置与数据加载分开:
release: bundle exec rake db:migrate
然后将其他postdeploy
步骤保留在app.json
文件中。
...
"scripts": {
"postdeploy": "bundle exec rake db:seed && bundle exec rake my_sample:load"
}
}```