X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server.js;h=5feb214764f183f10cd7f8b58e5407ff3ce0a98c;hb=a6375e69668ea42e19531c6bc68dcd37f3f7cbd7;hp=ca275ccec5df51351636b28951381cede16e8b5a;hpb=c4403b29ad4db097af528a7f04eea07e0ed320d0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.js b/server.js index ca275ccec..5feb21476 100644 --- a/server.js +++ b/server.js @@ -35,10 +35,7 @@ const installer = require('./server/initializers/installer') const migrator = require('./server/initializers/migrator') const mongoose = require('mongoose') const routes = require('./server/controllers') -const utils = require('./server/helpers/utils') -const webtorrent = require('./server/lib/webtorrent') const Request = mongoose.model('Request') -const Video = mongoose.model('Video') // Get configurations const port = config.get('listen.port') @@ -76,9 +73,16 @@ app.use('/client/*', function (req, res, next) { res.sendStatus(404) }) +const torrentsPhysicalPath = path.join(__dirname, config.get('storage.torrents')) +app.use(constants.STATIC_PATHS.TORRENTS, express.static(torrentsPhysicalPath, { maxAge: 0 })) + +// Uploads path for webseeding +const uploadsPhysicalPath = path.join(__dirname, config.get('storage.uploads')) +app.use(constants.STATIC_PATHS.WEBSEED, express.static(uploadsPhysicalPath, { maxAge: 0 })) + // Thumbnails path for express const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails')) -app.use(constants.THUMBNAILS_STATIC_PATH, express.static(thumbnailsPhysicalPath, { maxAge: 0 })) +app.use(constants.STATIC_PATHS.THUMBNAILS, express.static(thumbnailsPhysicalPath, { maxAge: 0 })) // Client application app.use('/*', function (req, res, next) { @@ -129,33 +133,14 @@ installer.installApplication(function (err) { migrator.migrate(function (err) { if (err) throw err - // Create/activate the webtorrent module - webtorrent.create(function () { - function cleanForExit () { - utils.cleanForExit(webtorrent.app) - } - - function exitGracefullyOnSignal () { - process.exit(-1) - } - - process.on('exit', cleanForExit) - process.on('SIGINT', exitGracefullyOnSignal) - process.on('SIGTERM', exitGracefullyOnSignal) - - // ----------- Make the server listening ----------- - server.listen(port, function () { - // Activate the pool requests - Request.activate() - - Video.seedAllExisting(function (err) { - if (err) throw err - - logger.info('Seeded all the videos') - logger.info('Server listening on port %d', port) - app.emit('ready') - }) - }) + // ----------- Make the server listening ----------- + server.listen(port, function () { + // Activate the pool requests + Request.activate() + + logger.info('Seeded all the videos') + logger.info('Server listening on port %d', port) + app.emit('ready') }) }) })