const logger = require('./server/helpers/logger')
// Initialize database and models
const db = require('./server/initializers/database')
-db.init()
+db.init(onDatabaseInitDone)
// ----------- Checker -----------
const checker = require('./server/initializers/checker')
if (missed.length !== 0) {
throw new Error('Miss some configurations keys : ' + missed)
}
+checker.checkFFmpeg(function (err) {
+ if (err) {
+ throw err
+ }
+})
const errorMessage = checker.checkConfig()
if (errorMessage !== null) {
// ----------- PeerTube modules -----------
const customValidators = require('./server/helpers/custom-validators')
+const friends = require('./server/lib/friends')
const installer = require('./server/initializers/installer')
const migrator = require('./server/initializers/migrator')
+const jobScheduler = require('./server/lib/jobs/job-scheduler')
const routes = require('./server/controllers')
// ----------- Command line -----------
customValidators.misc,
customValidators.pods,
customValidators.users,
- customValidators.videos
+ customValidators.videos,
+ customValidators.remote.videos
)
}))
// ----------- Run -----------
-const port = constants.CONFIG.LISTEN.PORT
-installer.installApplication(function (err) {
- if (err) throw err
-
- // Run the migration scripts if needed
+function onDatabaseInitDone () {
+ const port = constants.CONFIG.LISTEN.PORT
+ // Run the migration scripts if needed
migrator.migrate(function (err) {
if (err) throw err
- // ----------- Make the server listening -----------
- server.listen(port, function () {
- // Activate the pool requests
- db.Request.activate()
+ installer.installApplication(function (err) {
+ if (err) throw err
+
+ // ----------- Make the server listening -----------
+ server.listen(port, function () {
+ // Activate the communication with friends
+ friends.activate()
- logger.info('Server listening on port %d', port)
- logger.info('Webserver: %s', constants.CONFIG.WEBSERVER.URL)
+ // Activate job scheduler
+ jobScheduler.activate()
- app.emit('ready')
+ logger.info('Server listening on port %d', port)
+ logger.info('Webserver: %s', constants.CONFIG.WEBSERVER.URL)
+
+ app.emit('ready')
+ })
})
})
-})
+}
module.exports = app