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')
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) {
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')
})
})
})