mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
log unhandled error
This commit is contained in:
parent
289f1cf5e2
commit
d41459a5cd
2 changed files with 22 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ import {
|
|||
import express, { Express } from 'express'
|
||||
import { appDataSource } from './data_source'
|
||||
import { env } from './env'
|
||||
import { aiSummarize, AI_SUMMARIZE_JOB_NAME } from './jobs/ai-summarize'
|
||||
import { bulkAction, BULK_ACTION_JOB_NAME } from './jobs/bulk_action'
|
||||
import { callWebhook, CALL_WEBHOOK_JOB_NAME } from './jobs/call_webhook'
|
||||
import { findThumbnail, THUMBNAIL_JOB } from './jobs/find_thumbnail'
|
||||
|
|
@ -43,7 +44,6 @@ import { redisDataSource } from './redis_data_source'
|
|||
import { CACHED_READING_POSITION_PREFIX } from './services/cached_reading_position'
|
||||
import { getJobPriority } from './utils/createTask'
|
||||
import { logger } from './utils/logger'
|
||||
import { AI_SUMMARIZE_JOB_NAME, aiSummarize } from './jobs/ai-summarize'
|
||||
|
||||
export const QUEUE_NAME = 'omnivore-backend-queue'
|
||||
export const JOB_VERSION = 'v001'
|
||||
|
|
@ -256,6 +256,16 @@ const main = async () => {
|
|||
|
||||
process.on('SIGINT', () => gracefulShutdown('SIGINT'))
|
||||
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'))
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
// Handle the error safely
|
||||
logger.error('Uncaught exception', err)
|
||||
})
|
||||
|
||||
process.on('unhandledRejection', (reason, promise) => {
|
||||
// Handle the error safely
|
||||
logger.error('Unhandled Rejection at: Promise', { promise, reason })
|
||||
})
|
||||
}
|
||||
|
||||
// only call main if the file was called from the CLI and wasn't required from another module
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import {
|
|||
isSystemRequest,
|
||||
} from './utils/auth'
|
||||
import { corsConfig } from './utils/corsConfig'
|
||||
import { buildLogger, buildLoggerTransport } from './utils/logger'
|
||||
import { buildLogger, buildLoggerTransport, logger } from './utils/logger'
|
||||
import { aiSummariesRouter } from './routers/ai_summary_router'
|
||||
|
||||
const PORT = process.env.PORT || 4000
|
||||
|
|
@ -247,6 +247,16 @@ const main = async (): Promise<void> => {
|
|||
|
||||
process.on('SIGINT', () => gracefulShutdown('SIGINT'))
|
||||
process.on('SIGTERM', () => gracefulShutdown('SIGTERM'))
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
// Handle the error safely
|
||||
logger.error('Uncaught exception', err)
|
||||
})
|
||||
|
||||
process.on('unhandledRejection', (reason, promise) => {
|
||||
// Handle the error safely
|
||||
logger.error('Unhandled Rejection at: Promise', { promise, reason })
|
||||
})
|
||||
}
|
||||
|
||||
// only call main if the file was called from the CLI and wasn't required from another module
|
||||
|
|
|
|||
Loading…
Reference in a new issue