diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-09 13:15:40 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-09 13:15:40 +0100 |
commit | 1e9d7b60cd93ad5d1aed47fd157f1993d4b4eac0 (patch) | |
tree | 4b15a32c622877c93ca334f43be678856f99c14e | |
parent | 53ac1448f073a5db69f934550404c6997822501e (diff) | |
download | PeerTube-1e9d7b60cd93ad5d1aed47fd157f1993d4b4eac0.tar.gz PeerTube-1e9d7b60cd93ad5d1aed47fd157f1993d4b4eac0.tar.zst PeerTube-1e9d7b60cd93ad5d1aed47fd157f1993d4b4eac0.zip |
Fix crash with websocket tracker
-rw-r--r-- | server.ts | 5 | ||||
-rw-r--r-- | server/helpers/logger.ts | 4 |
2 files changed, 4 insertions, 5 deletions
@@ -104,11 +104,11 @@ const trackerServer = new TrackerServer({ | |||
104 | }) | 104 | }) |
105 | 105 | ||
106 | trackerServer.on('error', function (err) { | 106 | trackerServer.on('error', function (err) { |
107 | logger.error(err) | 107 | logger.error('Error in websocket tracker.', err) |
108 | }) | 108 | }) |
109 | 109 | ||
110 | trackerServer.on('warning', function (err) { | 110 | trackerServer.on('warning', function (err) { |
111 | logger.error(err) | 111 | logger.error('Warning in websocket tracker.', err) |
112 | }) | 112 | }) |
113 | 113 | ||
114 | const server = http.createServer(app) | 114 | const server = http.createServer(app) |
@@ -116,7 +116,6 @@ const wss = new WebSocketServer({ server: server, path: '/tracker/socket' }) | |||
116 | wss.on('connection', function (ws) { | 116 | wss.on('connection', function (ws) { |
117 | trackerServer.onWebSocketConnection(ws) | 117 | trackerServer.onWebSocketConnection(ws) |
118 | }) | 118 | }) |
119 | wss.on('error', err => logger.error('Error in websocket server.', err)) | ||
120 | 119 | ||
121 | const onHttpRequest = trackerServer.onHttpRequest.bind(trackerServer) | 120 | const onHttpRequest = trackerServer.onHttpRequest.bind(trackerServer) |
122 | app.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { action: 'announce' })) | 121 | app.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { action: 'announce' })) |
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index 7624b3cff..201ea2235 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts | |||
@@ -26,12 +26,12 @@ const loggerFormat = winston.format.printf((info) => { | |||
26 | if (additionalInfos === '{}') additionalInfos = '' | 26 | if (additionalInfos === '{}') additionalInfos = '' |
27 | else additionalInfos = ' ' + additionalInfos | 27 | else additionalInfos = ' ' + additionalInfos |
28 | 28 | ||
29 | if (info.message.stack !== undefined) info.message = info.message.stack | 29 | if (info.message && info.message.stack !== undefined) info.message = info.message.stack |
30 | return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` | 30 | return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` |
31 | }) | 31 | }) |
32 | 32 | ||
33 | const timestampFormatter = winston.format.timestamp({ | 33 | const timestampFormatter = winston.format.timestamp({ |
34 | format: 'YYYY-MM-DD hh:mm:ss.SSS' | 34 | format: 'YYYY-MM-dd HH:mm:ss.SSS' |
35 | }) | 35 | }) |
36 | const labelFormatter = winston.format.label({ | 36 | const labelFormatter = winston.format.label({ |
37 | label | 37 | label |