diff options
Diffstat (limited to 'shared/server-commands/server')
-rw-r--r-- | shared/server-commands/server/config-command.ts | 34 | ||||
-rw-r--r-- | shared/server-commands/server/jobs.ts | 26 | ||||
-rw-r--r-- | shared/server-commands/server/server.ts | 20 | ||||
-rw-r--r-- | shared/server-commands/server/servers.ts | 2 |
4 files changed, 65 insertions, 17 deletions
diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.ts index 303fcab88..9a6e413f2 100644 --- a/shared/server-commands/server/config-command.ts +++ b/shared/server-commands/server/config-command.ts | |||
@@ -5,8 +5,9 @@ import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-comm | |||
5 | 5 | ||
6 | export class ConfigCommand extends AbstractCommand { | 6 | export class ConfigCommand extends AbstractCommand { |
7 | 7 | ||
8 | static getCustomConfigResolutions (enabled: boolean) { | 8 | static getCustomConfigResolutions (enabled: boolean, with0p = false) { |
9 | return { | 9 | return { |
10 | '0p': enabled && with0p, | ||
10 | '144p': enabled, | 11 | '144p': enabled, |
11 | '240p': enabled, | 12 | '240p': enabled, |
12 | '360p': enabled, | 13 | '360p': enabled, |
@@ -129,7 +130,8 @@ export class ConfigCommand extends AbstractCommand { | |||
129 | }) | 130 | }) |
130 | } | 131 | } |
131 | 132 | ||
132 | enableTranscoding (webtorrent = true, hls = true) { | 133 | // TODO: convert args to object |
134 | enableTranscoding (webtorrent = true, hls = true, with0p = false) { | ||
133 | return this.updateExistingSubConfig({ | 135 | return this.updateExistingSubConfig({ |
134 | newConfig: { | 136 | newConfig: { |
135 | transcoding: { | 137 | transcoding: { |
@@ -138,7 +140,7 @@ export class ConfigCommand extends AbstractCommand { | |||
138 | allowAudioFiles: true, | 140 | allowAudioFiles: true, |
139 | allowAdditionalExtensions: true, | 141 | allowAdditionalExtensions: true, |
140 | 142 | ||
141 | resolutions: ConfigCommand.getCustomConfigResolutions(true), | 143 | resolutions: ConfigCommand.getCustomConfigResolutions(true, with0p), |
142 | 144 | ||
143 | webtorrent: { | 145 | webtorrent: { |
144 | enabled: webtorrent | 146 | enabled: webtorrent |
@@ -151,6 +153,7 @@ export class ConfigCommand extends AbstractCommand { | |||
151 | }) | 153 | }) |
152 | } | 154 | } |
153 | 155 | ||
156 | // TODO: convert args to object | ||
154 | enableMinimumTranscoding (webtorrent = true, hls = true) { | 157 | enableMinimumTranscoding (webtorrent = true, hls = true) { |
155 | return this.updateExistingSubConfig({ | 158 | return this.updateExistingSubConfig({ |
156 | newConfig: { | 159 | newConfig: { |
@@ -173,6 +176,25 @@ export class ConfigCommand extends AbstractCommand { | |||
173 | }) | 176 | }) |
174 | } | 177 | } |
175 | 178 | ||
179 | enableRemoteTranscoding () { | ||
180 | return this.updateExistingSubConfig({ | ||
181 | newConfig: { | ||
182 | transcoding: { | ||
183 | remoteRunners: { | ||
184 | enabled: true | ||
185 | } | ||
186 | }, | ||
187 | live: { | ||
188 | transcoding: { | ||
189 | remoteRunners: { | ||
190 | enabled: true | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | }) | ||
196 | } | ||
197 | |||
176 | // --------------------------------------------------------------------------- | 198 | // --------------------------------------------------------------------------- |
177 | 199 | ||
178 | enableStudio () { | 200 | enableStudio () { |
@@ -363,6 +385,9 @@ export class ConfigCommand extends AbstractCommand { | |||
363 | }, | 385 | }, |
364 | transcoding: { | 386 | transcoding: { |
365 | enabled: true, | 387 | enabled: true, |
388 | remoteRunners: { | ||
389 | enabled: false | ||
390 | }, | ||
366 | allowAdditionalExtensions: true, | 391 | allowAdditionalExtensions: true, |
367 | allowAudioFiles: true, | 392 | allowAudioFiles: true, |
368 | threads: 1, | 393 | threads: 1, |
@@ -398,6 +423,9 @@ export class ConfigCommand extends AbstractCommand { | |||
398 | maxUserLives: 50, | 423 | maxUserLives: 50, |
399 | transcoding: { | 424 | transcoding: { |
400 | enabled: true, | 425 | enabled: true, |
426 | remoteRunners: { | ||
427 | enabled: false | ||
428 | }, | ||
401 | threads: 4, | 429 | threads: 4, |
402 | profile: 'default', | 430 | profile: 'default', |
403 | resolutions: { | 431 | resolutions: { |
diff --git a/shared/server-commands/server/jobs.ts b/shared/server-commands/server/jobs.ts index e1d6cdff4..ff3098063 100644 --- a/shared/server-commands/server/jobs.ts +++ b/shared/server-commands/server/jobs.ts | |||
@@ -1,16 +1,17 @@ | |||
1 | 1 | ||
2 | import { expect } from 'chai' | 2 | import { expect } from 'chai' |
3 | import { wait } from '@shared/core-utils' | 3 | import { wait } from '@shared/core-utils' |
4 | import { JobState, JobType } from '../../models' | 4 | import { JobState, JobType, RunnerJobState } from '../../models' |
5 | import { PeerTubeServer } from './server' | 5 | import { PeerTubeServer } from './server' |
6 | 6 | ||
7 | async function waitJobs ( | 7 | async function waitJobs ( |
8 | serversArg: PeerTubeServer[] | PeerTubeServer, | 8 | serversArg: PeerTubeServer[] | PeerTubeServer, |
9 | options: { | 9 | options: { |
10 | skipDelayed?: boolean // default false | 10 | skipDelayed?: boolean // default false |
11 | runnerJobs?: boolean // default false | ||
11 | } = {} | 12 | } = {} |
12 | ) { | 13 | ) { |
13 | const { skipDelayed = false } = options | 14 | const { skipDelayed = false, runnerJobs = false } = options |
14 | 15 | ||
15 | const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT | 16 | const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT |
16 | ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10) | 17 | ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10) |
@@ -33,7 +34,8 @@ async function waitJobs ( | |||
33 | // Check if each server has pending request | 34 | // Check if each server has pending request |
34 | for (const server of servers) { | 35 | for (const server of servers) { |
35 | for (const state of states) { | 36 | for (const state of states) { |
36 | const p = server.jobs.list({ | 37 | |
38 | const jobPromise = server.jobs.list({ | ||
37 | state, | 39 | state, |
38 | start: 0, | 40 | start: 0, |
39 | count: 10, | 41 | count: 10, |
@@ -46,17 +48,29 @@ async function waitJobs ( | |||
46 | } | 48 | } |
47 | }) | 49 | }) |
48 | 50 | ||
49 | tasks.push(p) | 51 | tasks.push(jobPromise) |
50 | } | 52 | } |
51 | 53 | ||
52 | const p = server.debug.getDebug() | 54 | const debugPromise = server.debug.getDebug() |
53 | .then(obj => { | 55 | .then(obj => { |
54 | if (obj.activityPubMessagesWaiting !== 0) { | 56 | if (obj.activityPubMessagesWaiting !== 0) { |
55 | pendingRequests = true | 57 | pendingRequests = true |
56 | } | 58 | } |
57 | }) | 59 | }) |
60 | tasks.push(debugPromise) | ||
61 | |||
62 | if (runnerJobs) { | ||
63 | const runnerJobsPromise = server.runnerJobs.list({ count: 100 }) | ||
64 | .then(({ data }) => { | ||
65 | for (const job of data) { | ||
66 | if (job.state.id !== RunnerJobState.COMPLETED) { | ||
67 | pendingRequests = true | ||
68 | } | ||
69 | } | ||
70 | }) | ||
71 | tasks.push(runnerJobsPromise) | ||
72 | } | ||
58 | 73 | ||
59 | tasks.push(p) | ||
60 | } | 74 | } |
61 | 75 | ||
62 | return tasks | 76 | return tasks |
diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index d7e751581..f68b81367 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts | |||
@@ -8,9 +8,9 @@ import { CLICommand } from '../cli' | |||
8 | import { CustomPagesCommand } from '../custom-pages' | 8 | import { CustomPagesCommand } from '../custom-pages' |
9 | import { FeedCommand } from '../feeds' | 9 | import { FeedCommand } from '../feeds' |
10 | import { LogsCommand } from '../logs' | 10 | import { LogsCommand } from '../logs' |
11 | import { SQLCommand } from '../miscs' | ||
12 | import { AbusesCommand } from '../moderation' | 11 | import { AbusesCommand } from '../moderation' |
13 | import { OverviewsCommand } from '../overviews' | 12 | import { OverviewsCommand } from '../overviews' |
13 | import { RunnerJobsCommand, RunnerRegistrationTokensCommand, RunnersCommand } from '../runners' | ||
14 | import { SearchCommand } from '../search' | 14 | import { SearchCommand } from '../search' |
15 | import { SocketIOCommand } from '../socket' | 15 | import { SocketIOCommand } from '../socket' |
16 | import { | 16 | import { |
@@ -136,7 +136,6 @@ export class PeerTubeServer { | |||
136 | streamingPlaylists?: StreamingPlaylistsCommand | 136 | streamingPlaylists?: StreamingPlaylistsCommand |
137 | channels?: ChannelsCommand | 137 | channels?: ChannelsCommand |
138 | comments?: CommentsCommand | 138 | comments?: CommentsCommand |
139 | sql?: SQLCommand | ||
140 | notifications?: NotificationsCommand | 139 | notifications?: NotificationsCommand |
141 | servers?: ServersCommand | 140 | servers?: ServersCommand |
142 | login?: LoginCommand | 141 | login?: LoginCommand |
@@ -150,6 +149,10 @@ export class PeerTubeServer { | |||
150 | videoToken?: VideoTokenCommand | 149 | videoToken?: VideoTokenCommand |
151 | registrations?: RegistrationsCommand | 150 | registrations?: RegistrationsCommand |
152 | 151 | ||
152 | runners?: RunnersCommand | ||
153 | runnerRegistrationTokens?: RunnerRegistrationTokensCommand | ||
154 | runnerJobs?: RunnerJobsCommand | ||
155 | |||
153 | constructor (options: { serverNumber: number } | { url: string }) { | 156 | constructor (options: { serverNumber: number } | { url: string }) { |
154 | if ((options as any).url) { | 157 | if ((options as any).url) { |
155 | this.setUrl((options as any).url) | 158 | this.setUrl((options as any).url) |
@@ -311,14 +314,14 @@ export class PeerTubeServer { | |||
311 | }) | 314 | }) |
312 | } | 315 | } |
313 | 316 | ||
314 | async kill () { | 317 | kill () { |
315 | if (!this.app) return | 318 | if (!this.app) return Promise.resolve() |
316 | |||
317 | await this.sql.cleanup() | ||
318 | 319 | ||
319 | process.kill(-this.app.pid) | 320 | process.kill(-this.app.pid) |
320 | 321 | ||
321 | this.app = null | 322 | this.app = null |
323 | |||
324 | return Promise.resolve() | ||
322 | } | 325 | } |
323 | 326 | ||
324 | private randomServer () { | 327 | private randomServer () { |
@@ -420,7 +423,6 @@ export class PeerTubeServer { | |||
420 | this.streamingPlaylists = new StreamingPlaylistsCommand(this) | 423 | this.streamingPlaylists = new StreamingPlaylistsCommand(this) |
421 | this.channels = new ChannelsCommand(this) | 424 | this.channels = new ChannelsCommand(this) |
422 | this.comments = new CommentsCommand(this) | 425 | this.comments = new CommentsCommand(this) |
423 | this.sql = new SQLCommand(this) | ||
424 | this.notifications = new NotificationsCommand(this) | 426 | this.notifications = new NotificationsCommand(this) |
425 | this.servers = new ServersCommand(this) | 427 | this.servers = new ServersCommand(this) |
426 | this.login = new LoginCommand(this) | 428 | this.login = new LoginCommand(this) |
@@ -433,5 +435,9 @@ export class PeerTubeServer { | |||
433 | this.twoFactor = new TwoFactorCommand(this) | 435 | this.twoFactor = new TwoFactorCommand(this) |
434 | this.videoToken = new VideoTokenCommand(this) | 436 | this.videoToken = new VideoTokenCommand(this) |
435 | this.registrations = new RegistrationsCommand(this) | 437 | this.registrations = new RegistrationsCommand(this) |
438 | |||
439 | this.runners = new RunnersCommand(this) | ||
440 | this.runnerRegistrationTokens = new RunnerRegistrationTokensCommand(this) | ||
441 | this.runnerJobs = new RunnerJobsCommand(this) | ||
436 | } | 442 | } |
437 | } | 443 | } |
diff --git a/shared/server-commands/server/servers.ts b/shared/server-commands/server/servers.ts index b2b61adb3..fe9da9e63 100644 --- a/shared/server-commands/server/servers.ts +++ b/shared/server-commands/server/servers.ts | |||
@@ -20,7 +20,7 @@ function createMultipleServers (totalServers: number, configOverride?: object, o | |||
20 | return Promise.all(serverPromises) | 20 | return Promise.all(serverPromises) |
21 | } | 21 | } |
22 | 22 | ||
23 | async function killallServers (servers: PeerTubeServer[]) { | 23 | function killallServers (servers: PeerTubeServer[]) { |
24 | return Promise.all(servers.map(s => s.kill())) | 24 | return Promise.all(servers.map(s => s.kill())) |
25 | } | 25 | } |
26 | 26 | ||