Merge pull request #23 from matrix-org/bwindels/restlogs

spit out logs for creating REST users to figure out what is going on …
pull/21833/head
Bruno Windels 2018-09-18 10:17:31 +02:00 committed by GitHub
commit 3de9f6efae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -35,11 +35,12 @@ module.exports = class RestSessionCreator {
async createSession(username, password) { async createSession(username, password) {
await this._register(username, password); await this._register(username, password);
console.log(` * created REST user ${username} ... done`);
const authResult = await this._authenticate(username, password); const authResult = await this._authenticate(username, password);
return new RestSession(authResult); return new RestSession(authResult);
} }
_register(username, password) { async _register(username, password) {
const registerArgs = [ const registerArgs = [
'-c homeserver.yaml', '-c homeserver.yaml',
`-u ${username}`, `-u ${username}`,
@ -55,11 +56,14 @@ module.exports = class RestSessionCreator {
registerCmd registerCmd
].join(';'); ].join(';');
return exec(allCmds, {cwd: this.cwd, encoding: 'utf-8'}).catch((result) => { try {
await exec(allCmds, {cwd: this.cwd, encoding: 'utf-8'});
} catch (result) {
const lines = result.stdout.trim().split('\n'); const lines = result.stdout.trim().split('\n');
const failureReason = lines[lines.length - 1]; const failureReason = lines[lines.length - 1];
throw new Error(`creating user ${username} failed: ${failureReason}`); const logs = (await exec("tail -n 100 synapse/installations/consent/homeserver.log")).stdout;
}); throw new Error(`creating user ${username} failed: ${failureReason}, synapse logs:\n${logs}`);
}
} }
async _authenticate(username, password) { async _authenticate(username, password) {