Skip to content

Commit 2694de7

Browse files
committed
Merge pull request #372 from uProxy/trevj-install-progress
emit install progress events
2 parents d8559dd + 26a057b commit 2694de7

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/cloud/deployer/freedom-module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ provisioner.start('test').then((serverInfo: any) => {
2222
log.info('server provisioned: %1', serverInfo);
2323

2424
const installer = freedom['cloudinstall']();
25+
26+
installer.on('progress', (progress: number) => {
27+
log.info('install progress: %1', progress);
28+
});
29+
2530
log.info('installing...');
2631
installer.install(serverInfo.network.ipv4, serverInfo.network.ssh_port,
2732
'root', serverInfo.ssh.private).then((invitation: string) => {

src/cloud/install/freedom-module.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
},
1818
"err": {
1919
"message": "string"
20+
},
21+
"progress": {
22+
"type": "event",
23+
"value": "number"
24+
},
25+
"status": {
26+
"type": "event",
27+
"value": "string"
2028
}
2129
}
2230
},

src/cloud/install/installer.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const INSTALL_COMMAND = 'curl -sSL https://raw.githubusercontent.com/uProxy/upro
2020
// Prefix for invitation URLs.
2121
const INVITATION_PREFIX = 'CLOUD_INSTANCE_DETAILS_JSON:';
2222

23+
// Prefix for progress updates.
24+
const PROGRESS_PREFIX = 'CLOUD_INSTALL_PROGRESS';
25+
26+
// Prefix for status updates.
27+
const STATUS_PREFIX = 'CLOUD_INSTALL_STATUS';
28+
2329
// Installs uProxy on a server, via SSH.
2430
// The process is as close as possible to a manual install
2531
// so that we have fewer paths to test.
@@ -65,6 +71,16 @@ class CloudInstaller {
6571
message: 'could not parse invite: ' + inviteJson
6672
});
6773
}
74+
} else if (line.indexOf(PROGRESS_PREFIX) === 0) {
75+
const tokens = line.split(' ');
76+
if (tokens.length < 2) {
77+
log.warn('could not parse progress update');
78+
} else {
79+
const progress = parseInt(tokens[1], 10);
80+
this.dispatchEvent_('progress', progress);
81+
}
82+
} else if (line.indexOf(STATUS_PREFIX) === 0) {
83+
this.dispatchEvent_('status', line);
6884
}
6985
});
7086

0 commit comments

Comments
 (0)