diff options
author | Chocobozzz <me@florianbigard.com> | 2020-09-17 09:20:52 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e (patch) | |
tree | 79304b0152b0a38d33b26e65d4acdad0da4032a7 /server.ts | |
parent | 110d463fece85e87a26aca48a6048ae0017a27b3 (diff) | |
download | PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.tar.gz PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.tar.zst PeerTube-c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e.zip |
Live streaming implementation first step
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -98,10 +98,12 @@ import { | |||
98 | staticRouter, | 98 | staticRouter, |
99 | lazyStaticRouter, | 99 | lazyStaticRouter, |
100 | servicesRouter, | 100 | servicesRouter, |
101 | liveRouter, | ||
101 | pluginsRouter, | 102 | pluginsRouter, |
102 | webfingerRouter, | 103 | webfingerRouter, |
103 | trackerRouter, | 104 | trackerRouter, |
104 | createWebsocketTrackerServer, botsRouter | 105 | createWebsocketTrackerServer, |
106 | botsRouter | ||
105 | } from './server/controllers' | 107 | } from './server/controllers' |
106 | import { advertiseDoNotTrack } from './server/middlewares/dnt' | 108 | import { advertiseDoNotTrack } from './server/middlewares/dnt' |
107 | import { Redis } from './server/lib/redis' | 109 | import { Redis } from './server/lib/redis' |
@@ -119,6 +121,7 @@ import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls' | |||
119 | import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler' | 121 | import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler' |
120 | import { Hooks } from './server/lib/plugins/hooks' | 122 | import { Hooks } from './server/lib/plugins/hooks' |
121 | import { PluginManager } from './server/lib/plugins/plugin-manager' | 123 | import { PluginManager } from './server/lib/plugins/plugin-manager' |
124 | import { LiveManager } from '@server/lib/live-manager' | ||
122 | 125 | ||
123 | // ----------- Command line ----------- | 126 | // ----------- Command line ----------- |
124 | 127 | ||
@@ -139,14 +142,14 @@ if (isTestInstance()) { | |||
139 | } | 142 | } |
140 | 143 | ||
141 | // For the logger | 144 | // For the logger |
142 | morgan.token<express.Request>('remote-addr', req => { | 145 | morgan.token('remote-addr', req => { |
143 | if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') { | 146 | if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') { |
144 | return anonymize(req.ip, 16, 16) | 147 | return anonymize(req.ip, 16, 16) |
145 | } | 148 | } |
146 | 149 | ||
147 | return req.ip | 150 | return req.ip |
148 | }) | 151 | }) |
149 | morgan.token<express.Request>('user-agent', req => { | 152 | morgan.token('user-agent', req => { |
150 | if (req.get('DNT') === '1') { | 153 | if (req.get('DNT') === '1') { |
151 | return useragent.parse(req.get('user-agent')).family | 154 | return useragent.parse(req.get('user-agent')).family |
152 | } | 155 | } |
@@ -183,6 +186,9 @@ app.use(apiRoute, apiRouter) | |||
183 | // Services (oembed...) | 186 | // Services (oembed...) |
184 | app.use('/services', servicesRouter) | 187 | app.use('/services', servicesRouter) |
185 | 188 | ||
189 | // Live streaming | ||
190 | app.use('/live', liveRouter) | ||
191 | |||
186 | // Plugins & themes | 192 | // Plugins & themes |
187 | app.use('/', pluginsRouter) | 193 | app.use('/', pluginsRouter) |
188 | 194 | ||
@@ -271,6 +277,9 @@ async function startApplication () { | |||
271 | 277 | ||
272 | if (cli.plugins) await PluginManager.Instance.registerPluginsAndThemes() | 278 | if (cli.plugins) await PluginManager.Instance.registerPluginsAndThemes() |
273 | 279 | ||
280 | LiveManager.Instance.init() | ||
281 | if (CONFIG.LIVE.ENABLED) LiveManager.Instance.run() | ||
282 | |||
274 | // Make server listening | 283 | // Make server listening |
275 | server.listen(port, hostname, () => { | 284 | server.listen(port, hostname, () => { |
276 | logger.info('Server listening on %s:%d', hostname, port) | 285 | logger.info('Server listening on %s:%d', hostname, port) |