mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fixed error reporting problems
This commit is contained in:
parent
c817bf5911
commit
0c62349802
@ -70,15 +70,20 @@ module.exports = {
|
||||
if (message) {
|
||||
const json = safeJsonParse(message.message);
|
||||
|
||||
if (json) logger.info(json);
|
||||
if (json) logger.log(json);
|
||||
else logger.info(message.message);
|
||||
|
||||
socket.emit(`runner-info-${runid}`, {
|
||||
const toEmit = {
|
||||
time: new Date(),
|
||||
severity: 'info',
|
||||
...message,
|
||||
message: json ? json.msg : message.message,
|
||||
});
|
||||
};
|
||||
|
||||
if (json && json.level >= 50) {
|
||||
toEmit.severity = 'error';
|
||||
}
|
||||
|
||||
socket.emit(`runner-info-${runid}`, toEmit);
|
||||
}
|
||||
},
|
||||
|
||||
@ -125,8 +130,9 @@ module.exports = {
|
||||
},
|
||||
}
|
||||
);
|
||||
const pipeDispatcher = severity => data =>
|
||||
this.dispatchMessage(runid, { severity, message: data.toString().trim() });
|
||||
const pipeDispatcher = severity => data => {
|
||||
return this.dispatchMessage(runid, { severity, message: data.toString().trim() });
|
||||
};
|
||||
|
||||
byline(subprocess.stdout).on('data', pipeDispatcher('info'));
|
||||
byline(subprocess.stderr).on('data', pipeDispatcher('error'));
|
||||
|
@ -11,7 +11,7 @@ async function runScript(func) {
|
||||
await func();
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
logger.error('Error running script', err);
|
||||
logger.error({ err }, `Error running script: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ export class DataDuplicator {
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error({ err }, 'Failed duplicator job, rollbacking');
|
||||
logger.error({ err }, `Failed duplicator job, rollbacking. ${err.message}`);
|
||||
await runCommandOnDriver(this.pool, this.driver, dmp => dmp.rollbackTransaction());
|
||||
return;
|
||||
}
|
||||
|
@ -14,23 +14,12 @@ export function createAsyncWriteStream(stream, options: AsyncWriteStreamOptions)
|
||||
});
|
||||
|
||||
writable._write = async (chunk, encoding, callback) => {
|
||||
await options.processItem(chunk);
|
||||
|
||||
// const { sql, id, newIdSql } = chunk;
|
||||
// if (_isArray(sql)) {
|
||||
// for (const item of sql) await driver.query(pool, item, { discardResult: true });
|
||||
// } else {
|
||||
// await driver.query(pool, sql, { discardResult: true });
|
||||
// }
|
||||
// if (newIdSql) {
|
||||
// const res = await driver.query(pool, newIdSql);
|
||||
// const resId = Object.entries(res?.rows?.[0])?.[0]?.[1];
|
||||
|
||||
// if (options?.mapResultId) {
|
||||
// options?.mapResultId(id, resId as string);
|
||||
// }
|
||||
// }
|
||||
callback();
|
||||
try {
|
||||
await options.processItem(chunk);
|
||||
callback(null);
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
};
|
||||
|
||||
// writable._final = async callback => {
|
||||
|
Loading…
Reference in New Issue
Block a user