Authored by xuqi

flush cdn

... ... @@ -11,6 +11,7 @@ import sh from 'shelljs';
import ssh from 'ssh2';
import fs from 'fs';
import path from 'path';
import rp from 'request-promise';
import config from '../../config/config';
import ws from '../../lib/ws';
... ... @@ -31,6 +32,11 @@ class Deploy {
return this._deploy().then(() => {
self._state('deploying');
}).then(() => {
self._flush();
self._state('flushing');
}).then(() => {
self._state('deploy success');
}).catch(e => {
console.error(e);
self._state('fail');
... ... @@ -59,13 +65,25 @@ class Deploy {
})
}
_flush() {
var self = this;
return rp({
uri: 'http://flushcache.yoho.cn/flushdaction.php',
type: 'GET',
qs: {
url: `http://cdn.yoho.cn/${self.project.name}/${self.building.version}/`
}
}).then(data => {
console.log(data);
});
}
async _state(state) {
ws.broadcast(`/deploy/${this.project._id}`, {
host: this.info.host,
state: state
});
await DeployInfo.updateState(this.info._id, state);
}
_log(msg) {
... ...
... ... @@ -162,8 +162,7 @@
});
ws.on('/deploy/{{project._id}}', function(data) {
console.log(data);
$('#d-' + data.host.replace(/\./g, '-')).find('b').text(data.state);
layer.msg(data.state);
});
});
ws.on('error', function() {
... ...
... ... @@ -55,6 +55,7 @@
"nedb": "^1.8.0",
"nedb-promise": "^2.0.0",
"qs": "^6.2.0",
"request-promise": "^4.1.1",
"shelljs": "^0.7.0",
"socket.io": "^1.4.6",
"ssh2": "^0.5.0",
... ...