-
Notifications
You must be signed in to change notification settings - Fork 2
/
backup.js
44 lines (34 loc) · 863 Bytes
/
backup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const coroutine = require('coroutine');
const config = require('./config');
const http = require("http");
let p;
function runSeed() {
p = process.start('fibos', ['seed.js']);
}
function endSeed() {
if (p) {
console.log('kill fibos');
p.kill(15);
}
console.log('sleep 1 s');
coroutine.sleep(1000);
}
runSeed();
syncData();
function syncData() {
console.log("start now ,waiting 10 s")
coroutine.sleep(10 * 1000);
const rep = http.post("http://127.0.0.1:8870/v1/chain/get_info", {
json: {}
});
const a = rep.json();
console.log("now head_block_num==> ",a.head_block_num);
endSeed();
console.log("tar =====>");
process.run('tar', ['-zcvf', config.backup_dir + "/data_" + a.head_block_num + ".tar.gz", config.data_dir]);
console.log("restart sync");
runSeed();
console.log("waiting 30 s");
coroutine.sleep(30 * 1000);
syncData()
}