Log unhandled errors in api and sync

This commit is contained in:
Juan Tejada 2016-07-11 17:42:49 -07:00
parent 039648bae8
commit 413a77c323
3 changed files with 15 additions and 7 deletions

View file

@ -14,6 +14,10 @@ const {DatabaseConnector, SchedulerUtils, Logger} = require(`nylas-core`);
global.Promise = require('bluebird');
global.Logger = Logger.createLogger('nylas-k2-api')
const onUnhandledError = (err) => global.Logger.fatal(err, 'Unhandled error')
process.on('uncaughtException', onUnhandledError)
process.on('unhandledRejection', onUnhandledError)
const server = new Hapi.Server({
connections: {
router: {

View file

@ -5,6 +5,10 @@ const SyncProcessManager = require('./sync-process-manager');
global.Logger = Logger.createLogger('nylas-k2-sync')
const onUnhandledError = (err) => global.Logger.fatal(err, 'Unhandled error')
process.on('uncaughtException', onUnhandledError)
process.on('unhandledRejection', onUnhandledError)
const manager = new SyncProcessManager();
DatabaseConnector.forShared().then((db) => {

View file

@ -61,13 +61,13 @@ class SyncProcessManager {
updateHeartbeat() {
const key = HEARTBEAT_FOR(IDENTITY);
const client = PubsubConnector.broadcastClient();
client.setAsync(key, Date.now()).then(() =>
client.expireAsync(key, HEARTBEAT_EXPIRES)
).then(() =>
this._logger.info({
accounts_syncing_count: Object.keys(this._workers).length,
}, "ProcessManager: 💘")
)
client.setAsync(key, Date.now())
.then(() => client.expireAsync(key, HEARTBEAT_EXPIRES))
.then(() => {
this._logger.info({
accounts_syncing_count: Object.keys(this._workers).length,
}, "ProcessManager: 💘")
})
}
onSigInt() {