X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server.js;h=9322bca19e500038fced0335f8a644a09c786248;hb=907e9510c28b4b2816cba0c070e3feaa16b10ac3;hp=989c60477d14ea38b5f7ba025b7155b39052ca3f;hpb=bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.js b/server.js index 989c60477..9322bca19 100644 --- a/server.js +++ b/server.js @@ -21,25 +21,27 @@ if (miss.length !== 0) { throw new Error('Miss some configurations keys : ' + miss) } -// ----------- PeerTube modules ----------- +// ----------- Database ----------- const config = require('config') const constants = require('./server/initializers/constants') -const customValidators = require('./server/helpers/customValidators') const database = require('./server/initializers/database') -const installer = require('./server/initializers/installer') const logger = require('./server/helpers/logger') -const poolRequests = require('./server/lib/requestsScheduler') + +database.connect() + +// ----------- PeerTube modules ----------- +const customValidators = require('./server/helpers/customValidators') +const installer = require('./server/initializers/installer') +const mongoose = require('mongoose') const routes = require('./server/controllers') const utils = require('./server/helpers/utils') -const videos = require('./server/lib/videos') const webtorrent = require('./server/lib/webtorrent') +const Request = mongoose.model('Request') +const Video = mongoose.model('Video') // Get configurations const port = config.get('listen.port') -// ----------- Database ----------- -database.connect() - // ----------- Command line ----------- // ----------- App ----------- @@ -56,11 +58,6 @@ app.use(expressValidator({ // ----------- Views, routes and static files ----------- -// Livereload -app.use(require('connect-livereload')({ - port: 35729 -})) - // Catch sefaults require('segfault-handler').registerHandler() @@ -69,9 +66,9 @@ const apiRoute = '/api/' + constants.API_VERSION app.use(apiRoute, routes.api) // Static files -app.use('/app', express.static(path.join(__dirname, '/client'), { maxAge: 0 })) +app.use('/client', express.static(path.join(__dirname, '/client/dist'), { maxAge: 0 })) // 404 for static files not found -app.use('/app/*', function (req, res, next) { +app.use('/client/*', function (req, res, next) { res.sendStatus(404) }) @@ -81,7 +78,7 @@ app.use(constants.THUMBNAILS_STATIC_PATH, express.static(thumbnailsPhysicalPath, // Client application app.use('/*', function (req, res, next) { - res.sendFile(path.join(__dirname, 'client/index.html')) + res.sendFile(path.join(__dirname, 'client/dist/index.html')) }) // ----------- Tracker ----------- @@ -141,9 +138,11 @@ installer.installApplication(function (err) { // ----------- Make the server listening ----------- server.listen(port, function () { // Activate the pool requests - poolRequests.activate() + Request.activate() + + Video.seedAllExisting(function (err) { + if (err) throw err - videos.seedAllExisting(function () { logger.info('Seeded all the videos') logger.info('Server listening on port %d', port) app.emit('ready')