X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconstants.ts;h=0dab524d9cef3d4a07408f10d73e17927b3c1e37;hb=b65f5367baf799b425be0bcfb9220922751bb6eb;hp=cab61948acfff87efb9394f46d1d4fe7e5ea2b0d;hpb=63fa260a81a8930c157b73c897fe8696a8cc90d4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index cab61948a..0dab524d9 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -101,11 +101,6 @@ const SORTABLE_COLUMNS = { VIDEO_REDUNDANCIES: [ 'name' ] } -const OAUTH_LIFETIME = { - ACCESS_TOKEN: 3600 * 24, // 1 day, for upload - REFRESH_TOKEN: 1209600 // 2 weeks -} - const ROUTE_CACHE_LIFETIME = { FEEDS: '15 minutes', ROBOTS: '2 hours', @@ -169,7 +164,7 @@ const JOB_ATTEMPTS: { [id in JobType]: number } = { const JOB_CONCURRENCY: { [id in Exclude]: number } = { 'activitypub-http-broadcast': 1, 'activitypub-http-broadcast-parallel': 30, - 'activitypub-http-unicast': 10, + 'activitypub-http-unicast': 30, 'activitypub-http-fetcher': 3, 'activitypub-cleaner': 1, 'activitypub-follow': 1, @@ -239,7 +234,23 @@ const REQUEST_TIMEOUTS = { REDUNDANCY: JOB_TTL['video-redundancy'] } -const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days +const JOB_REMOVAL_OPTIONS = { + COUNT: 10000, // Max jobs to store + + SUCCESS: { // Success jobs + 'DEFAULT': parseDurationToMs('2 days'), + + 'activitypub-http-broadcast-parallel': parseDurationToMs('10 minutes'), + 'activitypub-http-unicast': parseDurationToMs('1 hour'), + 'videos-views-stats': parseDurationToMs('3 hours'), + 'activitypub-refresher': parseDurationToMs('10 hours') + }, + + FAILURE: { // Failed job + DEFAULT: parseDurationToMs('7 days') + } +} + const VIDEO_IMPORT_TIMEOUT = Math.floor(JOB_TTL['video-import'] * 0.9) const SCHEDULER_INTERVALS_MS = { @@ -662,10 +673,15 @@ const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = { // Express static paths (router) const STATIC_PATHS = { THUMBNAILS: '/static/thumbnails/', + WEBSEED: '/static/webseed/', + PRIVATE_WEBSEED: '/static/webseed/private/', + REDUNDANCY: '/static/redundancy/', + STREAMING_PLAYLISTS: { - HLS: '/static/streaming-playlists/hls' + HLS: '/static/streaming-playlists/hls', + PRIVATE_HLS: '/static/streaming-playlists/hls/private/' } } const STATIC_DOWNLOAD_PATHS = { @@ -680,6 +696,13 @@ const LAZY_STATIC_PATHS = { VIDEO_CAPTIONS: '/lazy-static/video-captions/', TORRENTS: '/lazy-static/torrents/' } +const OBJECT_STORAGE_PROXY_PATHS = { + PRIVATE_WEBSEED: '/object-storage-proxy/webseed/private/', + + STREAMING_PLAYLISTS: { + PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/' + } +} // Cache control const STATIC_MAX_AGE = { @@ -699,7 +722,7 @@ const PREVIEWS_SIZE = { height: 480, minWidth: 400 } -const ACTOR_IMAGES_SIZE: { [key in ActorImageType]: { width: number, height: number }[]} = { +const ACTOR_IMAGES_SIZE: { [key in ActorImageType]: { width: number, height: number }[] } = { [ActorImageType.AVATAR]: [ { width: 120, @@ -745,12 +768,35 @@ const LRU_CACHE = { }, ACTOR_IMAGE_STATIC: { MAX_SIZE: 500 + }, + STATIC_VIDEO_FILES_RIGHTS_CHECK: { + MAX_SIZE: 5000, + TTL: parseDurationToMs('10 seconds') + }, + VIDEO_TOKENS: { + MAX_SIZE: 100_000, + TTL: parseDurationToMs('8 hours') + }, + TRACKER_IPS: { + MAX_SIZE: 100_000 } } -const RESUMABLE_UPLOAD_DIRECTORY = join(CONFIG.STORAGE.TMP_DIR, 'resumable-uploads') -const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls') -const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') +const DIRECTORIES = { + RESUMABLE_UPLOAD: join(CONFIG.STORAGE.TMP_DIR, 'resumable-uploads'), + + HLS_STREAMING_PLAYLIST: { + PUBLIC: join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls'), + PRIVATE: join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls', 'private') + }, + + VIDEOS: { + PUBLIC: CONFIG.STORAGE.VIDEOS_DIR, + PRIVATE: join(CONFIG.STORAGE.VIDEOS_DIR, 'private') + }, + + HLS_REDUNDANCY: join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') +} const RESUMABLE_UPLOAD_SESSION_LIFETIME = SCHEDULER_INTERVALS_MS.REMOVE_DANGLING_RESUMABLE_UPLOADS @@ -776,7 +822,7 @@ const VIDEO_LIVE = { const MEMOIZE_TTL = { OVERVIEWS_SAMPLE: 1000 * 3600 * 4, // 4 hours - INFO_HASH_EXISTS: 1000 * 3600 * 12, // 12 hours + INFO_HASH_EXISTS: 1000 * 60, // 1 minute VIDEO_DURATION: 1000 * 10, // 10 seconds LIVE_ABLE_TO_UPLOAD: 1000 * 60, // 1 minute LIVE_CHECK_SOCKET_HEALTH: 1000 * 60, // 1 minute @@ -796,14 +842,6 @@ const WORKER_THREADS = { PROCESS_IMAGE: { CONCURRENCY: 1, MAX_THREADS: 5 - }, - SEQUENTIAL_HTTP_BROADCAST: { - CONCURRENCY: 1, - MAX_THREADS: 1 - }, - PARALLEL_HTTP_BROADCAST: { - CONCURRENCY: JOB_CONCURRENCY['activitypub-http-broadcast-parallel'], - MAX_THREADS: 1 } } @@ -844,7 +882,7 @@ const TRACKER_RATE_LIMITS = { INTERVAL: 60000 * 5, // 5 minutes ANNOUNCES_PER_IP_PER_INFOHASH: 15, // maximum announces per torrent in the interval ANNOUNCES_PER_IP: 30, // maximum announces for all our torrents in the interval - BLOCK_IP_LIFETIME: 60000 * 3 // 3 minutes + BLOCK_IP_LIFETIME: parseDurationToMs('3 minutes') } const P2P_MEDIA_LOADER_PEER_VERSION = 2 @@ -914,6 +952,8 @@ if (process.env.PRODUCTION_CONSTANTS !== 'true') { OVERVIEWS.VIDEOS.SAMPLE_THRESHOLD = 2 PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 5000 + + JOB_REMOVAL_OPTIONS.SUCCESS['videos-views-stats'] = 10000 } if (isTestInstance()) { @@ -970,10 +1010,10 @@ export { VIDEO_LIVE, PEERTUBE_VERSION, LAZY_STATIC_PATHS, + OBJECT_STORAGE_PROXY_PATHS, SEARCH_INDEX, - RESUMABLE_UPLOAD_DIRECTORY, + DIRECTORIES, RESUMABLE_UPLOAD_SESSION_LIFETIME, - HLS_REDUNDANCY_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, ACTOR_IMAGES_SIZE, ACCEPT_HEADERS, @@ -988,7 +1028,6 @@ export { JOB_ATTEMPTS, AP_CLEANER, LAST_MIGRATION_VERSION, - OAUTH_LIFETIME, CUSTOM_HTML_TAG_COMMENTS, STATS_TIMESERIE, BROADCAST_CONCURRENCY, @@ -1007,7 +1046,6 @@ export { VIDEO_FILTERS, ROUTE_CACHE_LIFETIME, SORTABLE_COLUMNS, - HLS_STREAMING_PLAYLIST_DIRECTORY, JOB_TTL, DEFAULT_THEME_NAME, NSFW_POLICY_TYPES, @@ -1046,7 +1084,7 @@ export { CRAWL_REQUEST_CONCURRENCY, DEFAULT_AUDIO_RESOLUTION, BINARY_CONTENT_TYPES, - JOB_COMPLETED_LIFETIME, + JOB_REMOVAL_OPTIONS, HTTP_SIGNATURE, VIDEO_IMPORT_STATES, VIDEO_CHANNEL_SYNC_STATE, @@ -1193,6 +1231,7 @@ function buildLanguages () { const additionalLanguages = { sgn: true, // Sign languages (macro language) ase: true, // American sign language + asq: true, // Austrian sign language sdl: true, // Arabian sign language bfi: true, // British sign language bzs: true, // Brazilian sign language