跳到主要內容

GAE上傳專案錯誤處理 - appcfg rollback

GAE是Google Cloud Platform上的一個大服務,提供穩定且自動Scale的平台,一般操作都是透過Eclipse的外掛來開發,但是今天遇到一個上傳不上去的問題... IDE卻沒有提供操作Function可以處理(或是我沒看到@@),重開Eclipse數次未能解決...

經由log檔案提供的資訊,針對AppEngine的Command Line服務來下手.... 一般user可以在Eclipse的plugin folder的下面路徑底下找到相關的執行檔案:

    $ ~/opt/eclipse-juno-SR2/plugins/com.google.appengine.eclipse.sdkbundle_1.7.6/appengine-java-sdk-1.7.6/bin/
中間的"sdkbundle_..."要視SDK版本而定,操作時候記得將權限開放給操作者使用(ex: Mac user需要透過chmod來開放執行權限..)
處理AppEngine無法上傳之問題,錯誤:

    com.google.appengine.tools.admin.HttpIoException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=gae-project-name&version=2&  409 Conflict  Another transaction by user simonsu is already in progress for app: s~gae-project-name, version: 2. That user can undo the transaction with "appcfg rollback".
操作描述:

    $ cd ~/opt/eclipse-juno-SR2/plugins/com.google.appengine.eclipse.sdkbundle_1.7.6/appengine-java-sdk-1.7.6/bin/  $ appcfg.sh update war/  ********************************************************  There is a new version of the SDK available.  -----------  Latest SDK:  Release: 1.8.6  Timestamp: Fri Sep 27 05:18:08 CST 2013  API versions: [1.0]    -----------  Your SDK:  Release: 1.7.6  Timestamp: Sat Mar 16 09:18:56 CST 2013  API versions: [1.0]    -----------  Please visit https://developers.google.com/appengine/downloads for the latest SDK.  ********************************************************  Reading application configuration data...  十月 16, 2013 11:56:37 下午 com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml  INFO: Successfully processed war/WEB-INF/appengine-web.xml  十月 16, 2013 11:56:37 下午 com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml  INFO: Successfully processed war/WEB-INF/web.xml  Beginning server interaction for gae-project-name...  Email: [your account]  Password for [your account]:
0% Created staging directory at: '/var/folders/n3/4xxf8_pd5kl1qr4wjgt8p8600000gn/T/appcfg4648333373954393727.tmp' 5% Using java7 runtime: true 8% Scanning for jsp files. 20% Scanning files on local disk. 25% Initiating update. com.google.appengine.tools.admin.HttpIoException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=gae-project-name&version=2& 409 Conflict Another transaction by user [your account] is already in progress for app: s~gae-project-name, version: 2. That user can undo the transaction with "appcfg rollback".
Unable to update app: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=gae-project-name&version=2& 409 Conflict Another transaction by user [your account] is already in progress for app: s~gae-project-name, version: 2. That user can undo the transaction with "appcfg rollback".
Please see the logs [/var/folders/n3/4xxf8_pd5kl1qr4wjgt8p8600000gn/T/appcfg1291090110446622014.log] for further information.
上面範例提示操作Log位置,直接檢視錯誤訊息:

    $ cat /var/folders/n3/4xxf8_pd5kl1qr4wjgt8p8600000gn/T/appcfg1291090110446622014.log  Unable to update:  com.google.appengine.tools.admin.HttpIoException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=gae-project-name&version=2&  409 Conflict  Another transaction by user [your account] is already in progress for app: s~gae-project-name, version: 2. That user can undo the transaction with "appcfg rollback".
at com.google.appengine.tools.admin.AbstractServerConnection.send1(AbstractServerConnection.java:293) at com.google.appengine.tools.admin.AbstractServerConnection.send(AbstractServerConnection.java:253) at com.google.appengine.tools.admin.AbstractServerConnection.post(AbstractServerConnection.java:232) at com.google.appengine.tools.admin.AppVersionUpload.send(AppVersionUpload.java:644) at com.google.appengine.tools.admin.AppVersionUpload.beginTransaction(AppVersionUpload.java:449) at com.google.appengine.tools.admin.AppVersionUpload.doUpload(AppVersionUpload.java:124) at com.google.appengine.tools.admin.AppAdminImpl.doUpdate(AppAdminImpl.java:371) at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:53) at com.google.appengine.tools.admin.AppCfg$UpdateAction.execute(AppCfg.java:1163) at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:232) at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:109) at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:105) com.google.appengine.tools.admin.AdminException: Unable to update app: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=gae-project-name&version=2& 409 Conflict Another transaction by user [your account] is already in progress for app: s~gae-project-name, version: 2. That user can undo the transaction with "appcfg rollback".
at com.google.appengine.tools.admin.AppAdminImpl.doUpdate(AppAdminImpl.java:376) at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:53) at com.google.appengine.tools.admin.AppCfg$UpdateAction.execute(AppCfg.java:1163) at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:232) at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:109) at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:105) Caused by: com.google.appengine.tools.admin.HttpIoException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=gae-project-name&version=2& 409 Conflict Another transaction by user [your account] is already in progress for app: s~gae-project-name, version: 2. That user can undo the transaction with "appcfg rollback".
at com.google.appengine.tools.admin.AbstractServerConnection.send1(AbstractServerConnection.java:293) at com.google.appengine.tools.admin.AbstractServerConnection.send(AbstractServerConnection.java:253) at com.google.appengine.tools.admin.AbstractServerConnection.post(AbstractServerConnection.java:232) at com.google.appengine.tools.admin.AppVersionUpload.send(AppVersionUpload.java:644) at com.google.appengine.tools.admin.AppVersionUpload.beginTransaction(AppVersionUpload.java:449) at com.google.appengine.tools.admin.AppVersionUpload.doUpload(AppVersionUpload.java:124) at com.google.appengine.tools.admin.AppAdminImpl.doUpdate(AppAdminImpl.java:371) ... 5 more
使用rollback方式,中斷未完成的transaction...

    $ ./appcfg.sh rollback war/  Reading application configuration data...  十月 16, 2013 11:57:22 下午 com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml  INFO: Successfully processed war/WEB-INF/appengine-web.xml  十月 16, 2013 11:57:22 下午 com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml  INFO: Successfully processed war/WEB-INF/web.xml  Beginning server interaction for gae-project-name...  0% Rolling back the update.  Success.  Cleaning up temporary files...
完成後,即可重新上傳project啦!

    $ ./appcfg.sh update war/  Reading application configuration data...  十月 16, 2013 11:57:31 下午 com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml  INFO: Successfully processed war/WEB-INF/appengine-web.xml  十月 16, 2013 11:57:31 下午 com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml  INFO: Successfully processed war/WEB-INF/web.xml  Beginning server interaction for gae-project-name...  0% Created staging directory at: '/var/folders/n3/4xxf8_pd5kl1qr4wjgt8p8600000gn/T/appcfg4902577019168099900.tmp'  5% Using java7 runtime: true  8% Scanning for jsp files.  20% Scanning files on local disk.  25% Initiating update.  28% Cloning 2 static files.  31% Cloning 78 application files.  40% Uploading 4 files.  52% Uploaded 1 files.  61% Uploaded 2 files.  68% Uploaded 3 files.  73% Uploaded 4 files.  77% Initializing precompilation...  80% Sending batch containing 4 file(s) totaling 13KB.  90% Deploying new version.  95% Closing update: new version is ready to start serving.  98% Uploading index definitions.    Update completed successfully.  Success.  Cleaning up temporary files...

留言

這個網誌中的熱門文章

Google指令碼基本操作介紹 - Web Server篇

Google的指令碼是什麼東西呢?!原則上他就是Google的一份靜態檔案,但是透過Google的雲端服務平台的一些能力,將靜態檔案內的scriptlet片段拉到Google的後端作運算,寫起來就像在寫JavaScript(這邊說Node.js可能比較貼切,因為同為server side language)或JSP,而在scriptlet片段中,則可以操作許多Google的API服務,甚至他提供你連接JDBC的能力、URL呼叫的能力...等,宛如就是一套完整的雲端程式語言(這樣說應該不為過拉,這真是個創新!),有並駕於App Engine的氣勢喔!
Google指令碼的範圍很廣,筆者也仍在摸索中,之前介紹過透過Sheet+指令碼做一個簡單的URL監控(這裡),而本篇簡單介紹一下指令碼如何製作一個Web Server(嚴格說起來是Web Page拉,但是具備Server端運作功能喔!)。您將可以體驗到No-Hosting Web Server的威力!
指令碼是Google Drive的一個服務,Google將指令碼(Code)以檔案方式寄存在Drive中,類似的靜態檔案服務的應用,最近滿火紅的!

首先開啟指令碼時候,選擇"作為網路應用程式的指令碼",檔案開啟後,會有愈設定程式碼片段供編輯


程式碼片段大致上如下,是一個doGet function,Web base的指令碼需要認得doGet()作為server的進入點 如果選擇到空白專案的話,只要把doGet function建上即可

作為一個Cloud IDE,Google當然也有把Code Hint擺上來,透過簡單的提示,寫啟程是來就更容易拉!

而Web部分物件的建立主要是透過HtmlService這個模組來進行操作,我們利用他來output html, load static html page, load template html page..等,範例如下:
Output HTML: // Script-as-app template.
function doGet(e) {
  return HtmlService.createHtmlOutput("<h1>HELLO!</h1>");
}
透過上HtmlService的createHtmlOutput的功能,…

透過Google Apps Script結合Google Form做即時郵件通知

體驗過Google Apps Script的功能後,也發現他結合GmailApps的模組GmailApps的應用可以用在表單填寫完成後,做發信的通知 例如您開立了一個訂購的表單,為了要在第一時間通知商家有訂單進入 就可以直接呼叫Gmail做發信的通知,讓手持Smart Phone的我們可以很快的知道生意上門了!
下面規劃三個function,其中: onCommit():為form commit時候觸發的function,需要掛載於form commit trigger上
jsonArrToTable():目的將json array解析成為一個Table
getLastRowTable():目的將整個table的回傳過濾為剩下第一筆(表頭,含有Form的欄位說明)與最後一筆(原則上就是剛剛送出的那一筆表單)完整程式碼如下: function onCommit(){
  var sheet = SpreadsheetApp.getActiveSheet();
  var rows = sheet.getDataRange();
  var numRows = rows.getNumRows();
  var values = rows.getValues();
  var content = getLastRowTable(values);
  var htmlBody = "Hi Admin: <br/><br/>有訂單拉,檢查一下吧! <br/><br/>" + content + '<br/><br/>Send by Google Apps';
  GmailApp.sendEmail(
    "your-email-address@gmail.com", 
    "Order Confirm Notice", 
    htmlBody, 
    {from: 'from-email-address@gmail.com', htmlBody:htmlBody}
  ); 
}
function getLastRowTable(arr){
  var newArr = new Array();
  newArr.p…

透過Google Cloud Storage建置您的靜態網站

大家知道靜態網站的服務越來越先進,透過Github Page或是S3都可以快速的建置好可以提供服務的靜態網站,這次要介紹的是Google Cloud Storage上建置靜態網站的功能...
首先我們先準備一個美美的靜態網站,不少人可能想到用PC的網頁編輯器,我這邊是使用Jetstrap的雲端服務來拉出基本的版型:


左上方的是提供下載專案的地方,下載之後可以解壓縮後看到裡面的html跟css相關檔案


接下來就是透過Google Cloud Storage來把這個些檔案變成一個網站囖,設定相當簡單...
Step 1 : 在Google Cloud Storage建置您的domain bucket,並把相關檔案上傳到這個bucket裡面
這邊需要先有Cloud Platform Project,並且開通好Cloud Storage的服務,這邊不贅述這些設定... 我在這邊建立的是gsweb.micloud.tw這個網站,因此bucket用這個命名(這邊必須注意,Google會針對domain name進行認證,如果domain name非自己所屬,或被別人註冊了,將無法使用該domain name來建立bucket),並且將檔案上傳,主頁修改為index.html。

這邊完成後,仍需要在最右邊的"SHARED PUBLICLY"的地方勾選發佈,讓全世界的人可以看到您的網站...
Step 2 : 透過gcutil將bucket變成一個網站
下面指令可以讓您設定一個bucket成為靜態網站,並且指定一個主頁,以及錯誤頁面,相關的help可以透過gsutil help setwebcfg來檢視...
$ gsutil web set -m index.html -e 404.html gs://gsweb.micloud.tw



Step 3 : 設定Domain name CNAME對應
接下來您需要到您的DNS server上指定一筆CNAME記錄,將yourdomain.com對應到c.storage.googleapis.com,指定完成後,在nslookup的查詢會類似這樣:


這也表示您的網站應該已經生效了: