Skip to content
This repository was archived by the owner on Dec 20, 2017. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,21 @@ function uploadFile(localFile, props, cb, retry, retries, lastErr) {
});
}

function loopLogs(opsToken, cb) {
function loopLogs(opsToken, prod, cb) {
var start = null;
var moreData = true;
var doLoop = function() {
var url = 'functions/_ops/progressive/' + opsToken;
var url = 'functions/_ops/progressive/' + opsToken + '?production=' + prod;
if (start) {
url += '?start=' + start;
url += '&start=' + start;
}
util.requestCloud(url, {}, 'GET', {
success: function(res) {
moreData = res.moreData;
var err = null;
res.logs.forEach(function(logInfo) {
console.log('%s [%s] %s', new Date(logInfo.createdAt).toLocaleString(), logInfo.level.toLocaleUpperCase(), logInfo.content);
start = logInfo.createdAt;
res.logs.reverse().forEach(function(logInfo) {
console.log('%s [%s] %s', new Date(logInfo.time).toLocaleString(), logInfo.level.toLocaleUpperCase(), logInfo.content);
start = logInfo.time;
if (logInfo.level.toLocaleUpperCase() === 'ERROR') {
err = logInfo.content;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ exports.deployLocalCloudCode = function (runtimeInfo, cloudPath, deployLog, cb)
log: deployLog
}, 'POST', {
success: function(resp) {
loopLogs(resp.opsToken, function(err) {
loopLogs(resp.opsToken, 0, function(err) {
if (err) {
return errorCb(cb, 128, "部署失败", err);
}
Expand Down Expand Up @@ -282,7 +282,7 @@ exports.deployGitCloudCode = function (revision, giturl, cb) {
url: giturl
}, 'POST', {
success: function(resp) {
loopLogs(resp.opsToken, function(err) {
loopLogs(resp.opsToken, 0, function(err) {
if (err) {
return errorCb(cb, 129, "从 Git 仓库部署", err);
}
Expand Down Expand Up @@ -310,7 +310,7 @@ exports.publishCloudCode = function(cb) {
initAVOSCloudSDK(function() {
util.requestCloud('functions/_ops/publish', {}, 'POST', {
success: function(resp) {
loopLogs(resp.opsToken, function(err) {
loopLogs(resp.opsToken, 1, function(err) {
if (err) {
return errorCb(cb, 130, "发布生产环境", err);
}
Expand Down Expand Up @@ -448,6 +448,9 @@ exports.viewCloudLog = function (lines, tailf, lastLogUpdatedTime, cb) {
}
util.requestCloud(url, {}, 'GET', {
success: function(resp) {
if (resp.results) {
resp = resp.results;
}
resp = resp.map(function(item) {
if (_.isString(item))
return JSON.parse(item);
Expand Down
1 change: 1 addition & 0 deletions lib/testUtilServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ app.get('/__engine/1/appInfo', function(req, res) {
res.send({
appId: app.get('appId'),
appKey: app.get('appKey'),
masterKey: app.get('masterKey'),
leanenginePort: app.get('leanenginePort')
});
});
Expand Down
12 changes: 6 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
<script type="text/javascript" src="https://cdn1.lncld.net/static/js/av-core-mini-0.5.4.js"></script>
<link rel="stylesheet" href="http://cdn.staticfile.org/twitter-bootstrap/3.3.1/css/bootstrap.min.css" type="text/css" media="screen"/>
<script type="text/javascript" charset="utf-8">
var appId, appKey, leanenginePort;
var appId, appKey, masterKey, leanenginePort;

$(document).ready(function (){

$.get("/__engine/1/appInfo", function(data) {
appId = data.appId;
appKey = data.appKey;
masterKey = data.masterKey;
leanenginePort = data.leanenginePort;
AV._initialize(appId, appKey, appKey);
AV._initialize(appId, appKey, masterKey);
AV._useMasterKey = true;
});

Expand All @@ -29,10 +30,9 @@
$('#hooks').find('option').remove().end();
$.get("/__engine/1/classes/" + className + "/actions", function (data){
_.each(data, function (name){
$('#hooks')
.append($("<option></option>")
.attr("value", "/" + name.className + "/" + name.action)
.text(name.action));
$('#hooks').append($("<option></option>")
.attr("value", "/" + name.className + "/" + name.action)
.text(name.action));
});
});
}
Expand Down