Compare commits

...

1 Commits

Author SHA1 Message Date
Alexander Chan b067dc53a0 add replication configuration file parser 2018-05-24 11:12:58 -07:00
1 changed files with 14 additions and 0 deletions

View File

@ -280,6 +280,9 @@ class Config extends EventEmitter {
if (process.env.S3_LOCATION_FILE !== undefined) { if (process.env.S3_LOCATION_FILE !== undefined) {
this.locationConfigPath = process.env.S3_LOCATION_FILE; this.locationConfigPath = process.env.S3_LOCATION_FILE;
} }
if (process.env.S3_REPLICATION_FILE !== undefined) {
this.replicationConfigPath = process.env.S3_REPLICATION_FILE;
}
// Read config automatically // Read config automatically
this._getLocationConfig(); this._getLocationConfig();
@ -351,6 +354,17 @@ class Config extends EventEmitter {
} catch (err) { } catch (err) {
throw new Error(`could not parse config file: ${err.message}`); throw new Error(`could not parse config file: ${err.message}`);
} }
if (this.replicationConfigPath) {
try {
const repData = fs.readFileSync(this.replicationConfigPath,
{ encoding: 'utf-8' });
const replicationEndpoints = JSON.parse(repData);
config.replicationEndpoints.push(...replicationEndpoints);
} catch (err) {
throw new Error(
`could not parse replication file: ${err.message}`);
}
}
this.port = 8000; this.port = 8000;
if (config.port !== undefined) { if (config.port !== undefined) {