aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/checker.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/checker.ts')
-rw-r--r--server/initializers/checker.ts52
1 files changed, 24 insertions, 28 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index 7007f2c0b..fb69e05fc 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -2,6 +2,7 @@ import * as config from 'config'
2 2
3import { database as db } from './database' 3import { database as db } from './database'
4import { CONFIG } from './constants' 4import { CONFIG } from './constants'
5import { promisify0 } from '../helpers/core-utils'
5 6
6// Some checks on configuration files 7// Some checks on configuration files
7function checkConfig () { 8function checkConfig () {
@@ -35,41 +36,36 @@ function checkMissedConfig () {
35} 36}
36 37
37// Check the available codecs 38// Check the available codecs
38function checkFFmpeg (callback: (err: Error) => void) { 39function checkFFmpeg () {
39 const Ffmpeg = require('fluent-ffmpeg') 40 const Ffmpeg = require('fluent-ffmpeg')
40 41 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs)
41 Ffmpeg.getAvailableCodecs(function (err, codecs) { 42
42 if (err) return callback(err) 43 getAvailableCodecsPromise()
43 if (CONFIG.TRANSCODING.ENABLED === false) return callback(null) 44 .then(codecs => {
44 45 if (CONFIG.TRANSCODING.ENABLED === false) return undefined
45 const canEncode = [ 'libx264' ] 46
46 canEncode.forEach(function (codec) { 47 const canEncode = [ 'libx264' ]
47 if (codecs[codec] === undefined) { 48 canEncode.forEach(function (codec) {
48 return callback(new Error('Unknown codec ' + codec + ' in FFmpeg.')) 49 if (codecs[codec] === undefined) {
49 } 50 throw new Error('Unknown codec ' + codec + ' in FFmpeg.')
50 51 }
51 if (codecs[codec].canEncode !== true) { 52
52 return callback(new Error('Unavailable encode codec ' + codec + ' in FFmpeg')) 53 if (codecs[codec].canEncode !== true) {
53 } 54 throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg')
55 }
56 })
54 }) 57 })
55
56 return callback(null)
57 })
58} 58}
59 59
60function clientsExist (callback: (err: Error, clientsExist?: boolean) => void) { 60function clientsExist () {
61 db.OAuthClient.countTotal(function (err, totalClients) { 61 return db.OAuthClient.countTotal().then(totalClients => {
62 if (err) return callback(err) 62 return totalClients !== 0
63
64 return callback(null, totalClients !== 0)
65 }) 63 })
66} 64}
67 65
68function usersExist (callback: (err: Error, usersExist?: boolean) => void) { 66function usersExist () {
69 db.User.countTotal(function (err, totalUsers) { 67 return db.User.countTotal().then(totalUsers => {
70 if (err) return callback(err) 68 return totalUsers !== 0
71
72 return callback(null, totalUsers !== 0)
73 }) 69 })
74} 70}
75 71