mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 17:13:58 +00:00
fixed error reporting problems
This commit is contained in:
@@ -70,15 +70,20 @@ module.exports = {
|
|||||||
if (message) {
|
if (message) {
|
||||||
const json = safeJsonParse(message.message);
|
const json = safeJsonParse(message.message);
|
||||||
|
|
||||||
if (json) logger.info(json);
|
if (json) logger.log(json);
|
||||||
else logger.info(message.message);
|
else logger.info(message.message);
|
||||||
|
|
||||||
socket.emit(`runner-info-${runid}`, {
|
const toEmit = {
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
severity: 'info',
|
|
||||||
...message,
|
...message,
|
||||||
message: json ? json.msg : message.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 =>
|
const pipeDispatcher = severity => data => {
|
||||||
this.dispatchMessage(runid, { severity, message: data.toString().trim() });
|
return this.dispatchMessage(runid, { severity, message: data.toString().trim() });
|
||||||
|
};
|
||||||
|
|
||||||
byline(subprocess.stdout).on('data', pipeDispatcher('info'));
|
byline(subprocess.stdout).on('data', pipeDispatcher('info'));
|
||||||
byline(subprocess.stderr).on('data', pipeDispatcher('error'));
|
byline(subprocess.stderr).on('data', pipeDispatcher('error'));
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ async function runScript(func) {
|
|||||||
await func();
|
await func();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Error running script', err);
|
logger.error({ err }, `Error running script: ${err.message}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ export class DataDuplicator {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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());
|
await runCommandOnDriver(this.pool, this.driver, dmp => dmp.rollbackTransaction());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,12 @@ export function createAsyncWriteStream(stream, options: AsyncWriteStreamOptions)
|
|||||||
});
|
});
|
||||||
|
|
||||||
writable._write = async (chunk, encoding, callback) => {
|
writable._write = async (chunk, encoding, callback) => {
|
||||||
|
try {
|
||||||
await options.processItem(chunk);
|
await options.processItem(chunk);
|
||||||
|
callback(null);
|
||||||
// const { sql, id, newIdSql } = chunk;
|
} catch (err) {
|
||||||
// if (_isArray(sql)) {
|
callback(err);
|
||||||
// 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();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// writable._final = async callback => {
|
// writable._final = async callback => {
|
||||||
|
|||||||
Reference in New Issue
Block a user