2014-01-17 32 views
1

我剛剛在GAE上實現了模塊,並試圖從某個模塊運行Cron作業。我的app.yaml的頂部有以下值:GAE Python - 在目標模塊上不執行Cron作業

application: myapp 
module: default 
version: 1 
runtime: python27 
api_version: 1 
threadsafe: true 

handlers: 
#all handlers 

對我試圖激活模塊reporting.yaml具有以下設置:

application: myapp 
module: reporting 
version: 1 
instance_class: B4 
runtime: python27 
api_version: 1 
threadsafe: true 

handlers: 
#same handlers as app.yaml 

最後我cron.yaml看起來如下:

cron: 
- description: update reports 
    url: /update 
    schedule: every day 12:00 
    target: reporting 

我需要模塊,因爲工作需要更多的內存,然後正常的實例提供。但是,出於某種原因,當我查看我的應用程序的日誌時,它會繼續在默認模塊上執行cron作業。爲什麼它不接受目標參數?

回答

1

原來我錯過了對模塊本身的上傳與下面的命令:

appcfg update app.yaml reporting.yaml 

這樣做後,目標參數的工作。

+0

你能告訴我如何正確設置你的cron工作的處理程序嗎?我有一個類似的問題,我試圖加載另一個需要更多內存的模塊......只是不知道如何設置處理程序以便將一個* .py腳本作爲cron作業運行。所以,舉個例子,我有abc.py,我想作爲module.yaml的一部分執行cron作業。預先感謝您 – user3058197

+0

另外,您是否必須更新dispatch.yaml?謝謝。 – user3058197

+0

我不使用distpatch.yaml,所以我想你不必更新它。在這種情況下,我的處理程序將是第一行「 - url:/ update」,然後是第二行「script:update.app」,它將從update.py中調用應用程序 – Vincent

0

請檢查以下文本GAE document - 版本不是模塊的目標元素。

如果目標參數已被設置爲一個作業,該請求被髮送到 指定版本

如何將您的目標模塊的向前cron作業如下面的示例代碼GAE document

import urllib2 
from google.appengine.api import modules 

url = "http://%s/" % modules.get_hostname(module="reporting") 
try: 
    result = urllib2.urlopen(url) 
    doSomethingWithResult(result) 
except urllib2.URLError, e: 
    handleError(e) 
+0

感謝您的輸入Wonil。原來,我只是需要正確地更新模塊。 – Vincent