英文:
Heroku. bash: apiworker: command not found
问题
我正在遵循这个 Heroku/Go 示例 https://github.com/heroku-examples/go_queue_example 来创建一个包含 web 和 worker 应用的项目。
通过 heroku local 命令可以正常运行应用,但是当部署到 Heroku 上时,日志中出现了以下 命令未找到的错误:
2016-03-20T11:55:51.029091+00:00 heroku[worker.1]: Starting process with command `apiworker`
2016-03-20T11:55:51.603896+00:00 heroku[worker.1]: State changed from starting to up
2016-03-20T11:55:52.842882+00:00 app[worker.1]: bash: apiworker: command not found
2016-03-20T11:55:53.624937+00:00 heroku[worker.1]: Process exited with status 127
2016-03-20T11:55:53.634515+00:00 heroku[worker.1]: State changed from up to crashed
2016-03-20T11:58:56.772069+00:00 heroku[web.1]: State changed from crashed to starting
2016-03-20T11:58:56.986655+00:00 heroku[web.1]: Starting process with command `apiweb`
2016-03-20T11:58:58.389926+00:00 app[web.1]: bash: apiweb: command not found
2016-03-20T11:58:59.060779+00:00 heroku[web.1]: State changed from starting to crashed
2016-03-20T11:58:59.049447+00:00 heroku[web.1]: Process exited with status 127
Procfile 文件内容如下:
web: apiweb
worker: apiworker
项目结构如下:
.
├── Godeps
│ ├── Godeps.json
│ └── Readme
├── Procfile
├── cmd
│ ├── apiweb
│ │ └── main.go
│ └── apiworker
│ └── main.go
├── vendor
<snip>
└── api.go
令人惊讶的是,在文档、这里以及其他地方搜索答案时,我几乎没有取得什么成功。非常感谢您的帮助!
英文:
I'm following this Heroku/Go example <https://github.com/heroku-examples/go_queue_example> for a web and worker app.
Running the app via heroku local works but when deploying to Heroku I get the following command not found errors in the log:
2016-03-20T11:55:51.029091+00:00 heroku[worker.1]: Starting process with command `apiworker`
2016-03-20T11:55:51.603896+00:00 heroku[worker.1]: State changed from starting to up
2016-03-20T11:55:52.842882+00:00 app[worker.1]: bash: apiworker: command not found
2016-03-20T11:55:53.624937+00:00 heroku[worker.1]: Process exited with status 127
2016-03-20T11:55:53.634515+00:00 heroku[worker.1]: State changed from up to crashed
2016-03-20T11:58:56.772069+00:00 heroku[web.1]: State changed from crashed to starting
2016-03-20T11:58:56.986655+00:00 heroku[web.1]: Starting process with command `apiweb`
2016-03-20T11:58:58.389926+00:00 app[web.1]: bash: apiweb: command not found
2016-03-20T11:58:59.060779+00:00 heroku[web.1]: State changed from starting to crashed
2016-03-20T11:58:59.049447+00:00 heroku[web.1]: Process exited with status 127
The Procfile:
web: apiweb
worker: apiworker
The project structure:
.
├── Godeps
│   ├── Godeps.json
│   └── Readme
├── Procfile
├── cmd
│   ├── apiweb
│   │   └── main.go
│   └── apiworker
│   └── main.go
├── vendor
<snip>
└── api.go
Surprisingly, I've had little success with searching for answers in the documentation, here, and elsewhere. Any help would be greatly appreciated!
答案1
得分: 1
有点晚了,但昨天我遇到了同样的问题,解决方法是重新保存依赖项。
在将主要文件移动到cmd文件夹后,你需要运行$ godep save ./cmd/...
,这会更新你的Godeps.json文件,但更重要的是它会添加/更新json中的"Packages"
字段,这个字段会被heroku的构建包(链接)用于运行$ go install
和$ godep go install
(链接)。
在重新保存依赖项之前,Godeps.json文件没有"Packages"
字段,因此构建包只会在项目的根目录中运行$ go install
,而不会安装cmd文件夹中的源代码,这将导致"command not found"错误。
英文:
A bit late, but i had the same issue yesterday and what worked for me was re-saving the dependencies.
After moving your mains to cmd, you need to run $ godep save ./cmd/...
, this of course then updates your Godeps.json file, but more importatnly it adds/updates the "Packages"
field in the json, which in turn is used by heroku's buildpack (link) to run $ go install
and $ godep go install
(link).
Before I re-saved my dependencies the Godeps.json file did not have a "Packages"
field and so the buildpack would run $ go install
only in the project's root folder and not installing the sources in the cmd folder, which would then result in the command not found
error.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论