|
@@ -11,6 +11,7 @@ import sh from 'shelljs'; |
|
@@ -11,6 +11,7 @@ import sh from 'shelljs'; |
11
|
import ssh from 'ssh2';
|
11
|
import ssh from 'ssh2';
|
12
|
import fs from 'fs';
|
12
|
import fs from 'fs';
|
13
|
import path from 'path';
|
13
|
import path from 'path';
|
|
|
14
|
+import rp from 'request-promise';
|
14
|
|
15
|
|
15
|
import config from '../../config/config';
|
16
|
import config from '../../config/config';
|
16
|
import ws from '../../lib/ws';
|
17
|
import ws from '../../lib/ws';
|
|
@@ -31,6 +32,11 @@ class Deploy { |
|
@@ -31,6 +32,11 @@ class Deploy { |
31
|
|
32
|
|
32
|
return this._deploy().then(() => {
|
33
|
return this._deploy().then(() => {
|
33
|
self._state('deploying');
|
34
|
self._state('deploying');
|
|
|
35
|
+ }).then(() => {
|
|
|
36
|
+ self._flush();
|
|
|
37
|
+ self._state('flushing');
|
|
|
38
|
+ }).then(() => {
|
|
|
39
|
+ self._state('deploy success');
|
34
|
}).catch(e => {
|
40
|
}).catch(e => {
|
35
|
console.error(e);
|
41
|
console.error(e);
|
36
|
self._state('fail');
|
42
|
self._state('fail');
|
|
@@ -59,13 +65,25 @@ class Deploy { |
|
@@ -59,13 +65,25 @@ class Deploy { |
59
|
})
|
65
|
})
|
60
|
}
|
66
|
}
|
61
|
|
67
|
|
|
|
68
|
+ _flush() {
|
|
|
69
|
+ var self = this;
|
|
|
70
|
+
|
|
|
71
|
+ return rp({
|
|
|
72
|
+ uri: 'http://flushcache.yoho.cn/flushdaction.php',
|
|
|
73
|
+ type: 'GET',
|
|
|
74
|
+ qs: {
|
|
|
75
|
+ url: `http://cdn.yoho.cn/${self.project.name}/${self.building.version}/`
|
|
|
76
|
+ }
|
|
|
77
|
+ }).then(data => {
|
|
|
78
|
+ console.log(data);
|
|
|
79
|
+ });
|
|
|
80
|
+ }
|
|
|
81
|
+
|
62
|
|
82
|
|
63
|
async _state(state) {
|
83
|
async _state(state) {
|
64
|
ws.broadcast(`/deploy/${this.project._id}`, {
|
84
|
ws.broadcast(`/deploy/${this.project._id}`, {
|
65
|
- host: this.info.host,
|
|
|
66
|
state: state
|
85
|
state: state
|
67
|
});
|
86
|
});
|
68
|
- await DeployInfo.updateState(this.info._id, state);
|
|
|
69
|
}
|
87
|
}
|
70
|
|
88
|
|
71
|
_log(msg) {
|
89
|
_log(msg) {
|