英文:
Queue doesn't work in production
问题
当我在本地测试我的网站时,一切正常。但是在生产环境中,我遇到了以下错误:无法获取任务:API错误1(taskqueue: UNKNOWN_QUEUE)
。
我相当确定我的代码是正确的,因为在本地可以正常工作。我最好的猜测是queue.yaml文件有问题,但它非常简单:
queue:
- name: daemonQueue
mode: pull
我可能做错了什么?
编辑:
事实证明,入队也失败了:TickTask入队错误:无法插入任务:API错误1(taskqueue: UNKNOWN_QUEUE)
。
以下是我如何将任务入队的代码。
// 将任务添加到队列中。
func EnqueueWithName(c sessions.Context, task interface{}, tag string, name string) (err error) {
buffer := new(bytes.Buffer)
err = gob.NewEncoder(buffer).Encode(task)
if err != nil {
return
}
newTask := &taskqueue.Task{
Method: "PULL",
Payload: buffer.Bytes(),
Tag: tag,
Name: name}
newTask, err = taskqueue.Add(c, newTask, "daemonQueue")
return err
}
英文:
When I'm testing my website locally everything works. But in production, I get the following error: Couldn't lease a task: API error 1 (taskqueue: UNKNOWN_QUEUE)
I'm pretty sure my code is correct since it works locally. My best guess is that there is something wrong with the queue.yaml file, but it's dead simple:
queue:
- name: daemonQueue
mode: pull
What could I be doing wrong?
EDIT:
Turns out enqueueing fails as well: TickTask enqueue error: Failed to insert task: API error 1 (taskqueue: UNKNOWN_QUEUE)
Here is how I'm enqueueing the task.
// Add the task to the queue.
func EnqueueWithName(c sessions.Context, task interface{}, tag string, name string) (err error) {
buffer := new(bytes.Buffer)
err = gob.NewEncoder(buffer).Encode(task)
if err != nil {
return
}
newTask := &taskqueue.Task{
Method: "PULL",
Payload: buffer.Bytes(),
Tag: tag,
Name: name}
newTask, err = taskqueue.Add(c, newTask, "daemonQueue")
return err
}
答案1
得分: 2
你在生产环境中没有配置队列。确保你部署整个应用程序目录,这样queue.yaml
才会被上传。将goapp deploy
或appcfg.py
指向包含app.yaml
和queue.yaml
的目录,而不是直接指向app.yaml
。
英文:
You don't have the queue configured in production. Make sure you are deploying your whole app directory so queue.yaml
get uploaded. Point goapp deploy
or appcfg.py
at the directory holding app.yaml
and queue.yaml
, not at app.yaml
directly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论