diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
commit | 88108880bbdba473cfe36ecbebc1c3c4f972e102 (patch) | |
tree | b242efb3b4f0d7e49d88f2d1f2063b5b3b0489c0 /server/initializers/installer.ts | |
parent | 53a94c7cfa8368da4cd248d65df8346905938f0c (diff) | |
parent | 9b712a2017e4ab3cf12cd6bd58278905520159d0 (diff) | |
download | PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.gz PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.zst PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.zip |
Merge branch 'develop' into pr/1217
Diffstat (limited to 'server/initializers/installer.ts')
-rw-r--r-- | server/initializers/installer.ts | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index c952ad46c..2b22e16fe 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -6,18 +6,27 @@ import { UserModel } from '../models/account/user' | |||
6 | import { ApplicationModel } from '../models/application/application' | 6 | import { ApplicationModel } from '../models/application/application' |
7 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 7 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
8 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' | 8 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' |
9 | import { CACHE, CONFIG, LAST_MIGRATION_VERSION } from './constants' | 9 | import { CACHE, CONFIG, HLS_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants' |
10 | import { sequelizeTypescript } from './database' | 10 | import { sequelizeTypescript } from './database' |
11 | import { remove, ensureDir } from 'fs-extra' | 11 | import { remove, ensureDir } from 'fs-extra' |
12 | 12 | ||
13 | async function installApplication () { | 13 | async function installApplication () { |
14 | try { | 14 | try { |
15 | await sequelizeTypescript.sync() | 15 | await Promise.all([ |
16 | await removeCacheDirectories() | 16 | // Database related |
17 | await createDirectoriesIfNotExist() | 17 | sequelizeTypescript.sync() |
18 | await createApplicationIfNotExist() | 18 | .then(() => { |
19 | await createOAuthClientIfNotExist() | 19 | return Promise.all([ |
20 | await createOAuthAdminIfNotExist() | 20 | createApplicationIfNotExist(), |
21 | createOAuthClientIfNotExist(), | ||
22 | createOAuthAdminIfNotExist() | ||
23 | ]) | ||
24 | }), | ||
25 | |||
26 | // Directories | ||
27 | removeCacheDirectories() | ||
28 | .then(() => createDirectoriesIfNotExist()) | ||
29 | ]) | ||
21 | } catch (err) { | 30 | } catch (err) { |
22 | logger.error('Cannot install application.', { err }) | 31 | logger.error('Cannot install application.', { err }) |
23 | process.exit(-1) | 32 | process.exit(-1) |
@@ -64,6 +73,9 @@ function createDirectoriesIfNotExist () { | |||
64 | tasks.push(ensureDir(dir)) | 73 | tasks.push(ensureDir(dir)) |
65 | } | 74 | } |
66 | 75 | ||
76 | // Playlist directories | ||
77 | tasks.push(ensureDir(HLS_PLAYLIST_DIRECTORY)) | ||
78 | |||
67 | return Promise.all(tasks) | 79 | return Promise.all(tasks) |
68 | } | 80 | } |
69 | 81 | ||