From 052937db8a8d282eccdbdf38d487ed8d85d3c0a7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 26 Jul 2016 22:30:46 +0200 Subject: First draft using only webseed for server --- server.js | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index b2eeeff70..0033ed1db 100644 --- a/server.js +++ b/server.js @@ -34,10 +34,7 @@ const customValidators = require('./server/helpers/custom-validators') const installer = require('./server/initializers/installer') 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') @@ -72,9 +69,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) { @@ -121,33 +125,14 @@ app.use(function (err, req, res, next) { installer.installApplication(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') }) }) -- cgit v1.2.3