From 2e980ed30dc37061b467ebbb68094f830bffdb5d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Jul 2021 12:07:26 +0200 Subject: [PATCH] Simplify createServer args --- server/tests/api/server/no-client.ts | 2 +- server/tools/test-live.ts | 2 +- shared/extra-utils/server/server.ts | 13 +++++++------ shared/extra-utils/server/servers.ts | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts index efa890ad4..719813ae9 100644 --- a/server/tests/api/server/no-client.ts +++ b/server/tests/api/server/no-client.ts @@ -9,7 +9,7 @@ describe('Start and stop server without web client routes', function () { before(async function () { this.timeout(30000) - server = await createSingleServer(1, {}, [ '--no-client' ]) + server = await createSingleServer(1, {}, { peertubeArgs: [ '--no-client' ] }) }) it('Should fail getting the client', function () { diff --git a/server/tools/test-live.ts b/server/tools/test-live.ts index 0cb0c3668..50dc04438 100644 --- a/server/tools/test-live.ts +++ b/server/tools/test-live.ts @@ -36,7 +36,7 @@ async function run () { console.log('Starting server.') - const server = await createSingleServer(1, {}, [], { hideLogs: false, execArgv: [ '--inspect' ] }) + const server = await createSingleServer(1, {}, { hideLogs: false, nodeArgs: [ '--inspect' ] }) const cleanup = async () => { console.log('Killing server') diff --git a/shared/extra-utils/server/server.ts b/shared/extra-utils/server/server.ts index b33bb9d1e..5bdcbac52 100644 --- a/shared/extra-utils/server/server.ts +++ b/shared/extra-utils/server/server.ts @@ -41,7 +41,8 @@ import { StatsCommand } from './stats-command' export type RunServerOptions = { hideLogs?: boolean - execArgv?: string[] + nodeArgs?: string[] + peertubeArgs?: string[] } export class PeerTubeServer { @@ -176,13 +177,13 @@ export class PeerTubeServer { this.port = parseInt(parsed.port) } - async flushAndRun (configOverride?: Object, args = [], options: RunServerOptions = {}) { + async flushAndRun (configOverride?: Object, options: RunServerOptions = {}) { await ServersCommand.flushTests(this.internalServerNumber) - return this.run(configOverride, args, options) + return this.run(configOverride, options) } - async run (configOverrideArg?: any, args = [], options: RunServerOptions = {}) { + async run (configOverrideArg?: any, options: RunServerOptions = {}) { // These actions are async so we need to be sure that they have both been done const serverRunString = { 'HTTP server listening': false @@ -215,13 +216,13 @@ export class PeerTubeServer { silent: true, env, detached: true, - execArgv: options.execArgv || [] + execArgv: options.nodeArgs || [] } return new Promise(res => { const self = this - this.app = fork(join(root(), 'dist', 'server.js'), args, forkOptions) + this.app = fork(join(root(), 'dist', 'server.js'), options.peertubeArgs || [], forkOptions) this.app.stdout.on('data', function onStdout (data) { let dontContinue = false diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 87d7e9449..f0622feb0 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -2,10 +2,10 @@ import { ensureDir } from 'fs-extra' import { isGithubCI } from '../miscs' import { PeerTubeServer, RunServerOptions } from './server' -async function createSingleServer (serverNumber: number, configOverride?: Object, args = [], options: RunServerOptions = {}) { +async function createSingleServer (serverNumber: number, configOverride?: Object, options: RunServerOptions = {}) { const server = new PeerTubeServer({ serverNumber }) - await server.flushAndRun(configOverride, args, options) + await server.flushAndRun(configOverride, options) return server }