X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fserver-commands%2Fserver%2Fserver.ts;h=66b7ff09d2702733423583fcdcbdca6cbf716612;hb=813f37438a1043876defb442c0b3eade198b3ca2;hp=c05d16ad2cb87285248adff27a1f30aa4de135a3;hpb=a3b472a12ec6e57dbe2f650419f8064864686eab;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index c05d16ad2..66b7ff09d 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts @@ -8,12 +8,21 @@ import { CLICommand } from '../cli' import { CustomPagesCommand } from '../custom-pages' import { FeedCommand } from '../feeds' import { LogsCommand } from '../logs' -import { SQLCommand } from '../miscs' import { AbusesCommand } from '../moderation' import { OverviewsCommand } from '../overviews' +import { RunnerJobsCommand, RunnerRegistrationTokensCommand, RunnersCommand } from '../runners' import { SearchCommand } from '../search' import { SocketIOCommand } from '../socket' -import { AccountsCommand, BlocklistCommand, LoginCommand, NotificationsCommand, SubscriptionsCommand, UsersCommand } from '../users' +import { + AccountsCommand, + BlocklistCommand, + LoginCommand, + NotificationsCommand, + RegistrationsCommand, + SubscriptionsCommand, + TwoFactorCommand, + UsersCommand +} from '../users' import { BlacklistCommand, CaptionsCommand, @@ -28,6 +37,7 @@ import { StreamingPlaylistsCommand, VideosCommand, VideoStudioCommand, + VideoTokenCommand, ViewsCommand } from '../videos' import { CommentsCommand } from '../videos/comments-command' @@ -37,6 +47,7 @@ import { ContactFormCommand } from './contact-form-command' import { DebugCommand } from './debug-command' import { FollowsCommand } from './follows-command' import { JobsCommand } from './jobs-command' +import { MetricsCommand } from './metrics-command' import { ObjectStorageCommand } from './object-storage-command' import { PluginsCommand } from './plugins-command' import { RedundancyCommand } from './redundancy-command' @@ -104,6 +115,7 @@ export class PeerTubeServer { debug?: DebugCommand follows?: FollowsCommand jobs?: JobsCommand + metrics?: MetricsCommand plugins?: PluginsCommand redundancy?: RedundancyCommand stats?: StatsCommand @@ -124,7 +136,6 @@ export class PeerTubeServer { streamingPlaylists?: StreamingPlaylistsCommand channels?: ChannelsCommand comments?: CommentsCommand - sql?: SQLCommand notifications?: NotificationsCommand servers?: ServersCommand login?: LoginCommand @@ -134,6 +145,13 @@ export class PeerTubeServer { videos?: VideosCommand videoStats?: VideoStatsCommand views?: ViewsCommand + twoFactor?: TwoFactorCommand + videoToken?: VideoTokenCommand + registrations?: RegistrationsCommand + + runners?: RunnersCommand + runnerRegistrationTokens?: RunnerRegistrationTokensCommand + runnerJobs?: RunnerJobsCommand constructor (options: { serverNumber: number } | { url: string }) { if ((options as any).url) { @@ -166,9 +184,9 @@ export class PeerTubeServer { this.rtmpsPort = this.parallel ? this.randomRTMP() : 1937 this.port = 9000 + this.internalServerNumber - this.url = `http://localhost:${this.port}` - this.host = `localhost:${this.port}` - this.hostname = 'localhost' + this.url = `http://127.0.0.1:${this.port}` + this.host = `127.0.0.1:${this.port}` + this.hostname = '127.0.0.1' } setUrl (url: string) { @@ -180,7 +198,13 @@ export class PeerTubeServer { this.port = parseInt(parsed.port) } - async flushAndRun (configOverride?: Object, options: RunServerOptions = {}) { + getDirectoryPath (directoryName: string) { + const testDirectory = 'test' + this.internalServerNumber + + return join(root(), testDirectory, directoryName) + } + + async flushAndRun (configOverride?: object, options: RunServerOptions = {}) { await ServersCommand.flushTests(this.internalServerNumber) return this.run(configOverride, options) @@ -226,7 +250,7 @@ export class PeerTubeServer { const forkOptions = { silent: true, env, - detached: true, + detached: false, execArgv } @@ -240,7 +264,7 @@ export class PeerTubeServer { const onPeerTubeExit = () => rej(new Error('Process exited:\n' + aggregatedLogs)) const onParentExit = () => { - if (!this.app || !this.app.pid) return + if (!this.app?.pid) return try { process.kill(self.app.pid) @@ -290,18 +314,18 @@ export class PeerTubeServer { }) } - async kill () { - if (!this.app) return - - await this.sql.cleanup() + kill () { + if (!this.app) return Promise.resolve() - process.kill(-this.app.pid) + process.kill(this.app.pid) this.app = null + + return Promise.resolve() } private randomServer () { - const low = 10 + const low = 2500 const high = 10000 return randomInt(low, high) @@ -339,19 +363,21 @@ export class PeerTubeServer { suffix: '_test' + this.internalServerNumber }, storage: { - tmp: `test${this.internalServerNumber}/tmp/`, - bin: `test${this.internalServerNumber}/bin/`, - avatars: `test${this.internalServerNumber}/avatars/`, - videos: `test${this.internalServerNumber}/videos/`, - streaming_playlists: `test${this.internalServerNumber}/streaming-playlists/`, - redundancy: `test${this.internalServerNumber}/redundancy/`, - logs: `test${this.internalServerNumber}/logs/`, - previews: `test${this.internalServerNumber}/previews/`, - thumbnails: `test${this.internalServerNumber}/thumbnails/`, - torrents: `test${this.internalServerNumber}/torrents/`, - captions: `test${this.internalServerNumber}/captions/`, - cache: `test${this.internalServerNumber}/cache/`, - plugins: `test${this.internalServerNumber}/plugins/` + tmp: this.getDirectoryPath('tmp') + '/', + tmp_persistent: this.getDirectoryPath('tmp-persistent') + '/', + bin: this.getDirectoryPath('bin') + '/', + avatars: this.getDirectoryPath('avatars') + '/', + videos: this.getDirectoryPath('videos') + '/', + streaming_playlists: this.getDirectoryPath('streaming-playlists') + '/', + redundancy: this.getDirectoryPath('redundancy') + '/', + logs: this.getDirectoryPath('logs') + '/', + previews: this.getDirectoryPath('previews') + '/', + thumbnails: this.getDirectoryPath('thumbnails') + '/', + torrents: this.getDirectoryPath('torrents') + '/', + captions: this.getDirectoryPath('captions') + '/', + cache: this.getDirectoryPath('cache') + '/', + plugins: this.getDirectoryPath('plugins') + '/', + well_known: this.getDirectoryPath('well-known') + '/' }, admin: { email: `admin${this.internalServerNumber}@example.com` @@ -377,6 +403,7 @@ export class PeerTubeServer { this.debug = new DebugCommand(this) this.follows = new FollowsCommand(this) this.jobs = new JobsCommand(this) + this.metrics = new MetricsCommand(this) this.plugins = new PluginsCommand(this) this.redundancy = new RedundancyCommand(this) this.stats = new StatsCommand(this) @@ -397,7 +424,6 @@ export class PeerTubeServer { this.streamingPlaylists = new StreamingPlaylistsCommand(this) this.channels = new ChannelsCommand(this) this.comments = new CommentsCommand(this) - this.sql = new SQLCommand(this) this.notifications = new NotificationsCommand(this) this.servers = new ServersCommand(this) this.login = new LoginCommand(this) @@ -407,5 +433,12 @@ export class PeerTubeServer { this.videoStudio = new VideoStudioCommand(this) this.videoStats = new VideoStatsCommand(this) this.views = new ViewsCommand(this) + this.twoFactor = new TwoFactorCommand(this) + this.videoToken = new VideoTokenCommand(this) + this.registrations = new RegistrationsCommand(this) + + this.runners = new RunnersCommand(this) + this.runnerRegistrationTokens = new RunnerRegistrationTokensCommand(this) + this.runnerJobs = new RunnerJobsCommand(this) } }