队列在生产环境中不起作用

huangapple go评论96阅读模式
英文:

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 deployappcfg.py指向包含app.yamlqueue.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.

huangapple
  • 本文由 发表于 2015年3月4日 09:36:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/28845253.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定