aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/installer.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-12 11:56:02 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-12 11:56:02 +0200
commitf981dae8617271a2dc713bb683951730b306e0c5 (patch)
treeecee631766bc1b98c20a7836479fed40850c5a56 /server/initializers/installer.ts
parent075f16caac5236cb04c98ae7b3a989766d764bb3 (diff)
downloadPeerTube-f981dae8617271a2dc713bb683951730b306e0c5.tar.gz
PeerTube-f981dae8617271a2dc713bb683951730b306e0c5.tar.zst
PeerTube-f981dae8617271a2dc713bb683951730b306e0c5.zip
Add previews cache system between pods
Diffstat (limited to 'server/initializers/installer.ts')
-rw-r--r--server/initializers/installer.ts30
1 files changed, 26 insertions, 4 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 1ec24c4ad..3c5a77df9 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -4,12 +4,13 @@ import * as passwordGenerator from 'password-generator'
4import * as Promise from 'bluebird' 4import * as Promise from 'bluebird'
5 5
6import { database as db } from './database' 6import { database as db } from './database'
7import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION } from './constants' 7import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION, CACHE } from './constants'
8import { clientsExist, usersExist } from './checker' 8import { clientsExist, usersExist } from './checker'
9import { logger, createCertsIfNotExist, root, mkdirpPromise } from '../helpers' 9import { logger, createCertsIfNotExist, root, mkdirpPromise, rimrafPromise } from '../helpers'
10 10
11function installApplication () { 11function installApplication () {
12 return db.sequelize.sync() 12 return db.sequelize.sync()
13 .then(() => removeCacheDirectories())
13 .then(() => createDirectoriesIfNotExist()) 14 .then(() => createDirectoriesIfNotExist())
14 .then(() => createCertsIfNotExist()) 15 .then(() => createCertsIfNotExist())
15 .then(() => createOAuthClientIfNotExist()) 16 .then(() => createOAuthClientIfNotExist())
@@ -24,13 +25,34 @@ export {
24 25
25// --------------------------------------------------------------------------- 26// ---------------------------------------------------------------------------
26 27
28function removeCacheDirectories () {
29 const cacheDirectories = CACHE.DIRECTORIES
30
31 const tasks = []
32
33 // Cache directories
34 Object.keys(cacheDirectories).forEach(key => {
35 const dir = cacheDirectories[key]
36 tasks.push(rimrafPromise(dir))
37 })
38
39 return Promise.all(tasks)
40}
41
27function createDirectoriesIfNotExist () { 42function createDirectoriesIfNotExist () {
28 const storages = config.get('storage') 43 const storages = CONFIG.STORAGE
44 const cacheDirectories = CACHE.DIRECTORIES
29 45
30 const tasks = [] 46 const tasks = []
31 Object.keys(storages).forEach(key => { 47 Object.keys(storages).forEach(key => {
32 const dir = storages[key] 48 const dir = storages[key]
33 tasks.push(mkdirpPromise(join(root(), dir))) 49 tasks.push(mkdirpPromise(dir))
50 })
51
52 // Cache directories
53 Object.keys(cacheDirectories).forEach(key => {
54 const dir = cacheDirectories[key]
55 tasks.push(mkdirpPromise(dir))
34 }) 56 })
35 57
36 return Promise.all(tasks) 58 return Promise.all(tasks)