export type RunServerOptions = {
hideLogs?: boolean
- execArgv?: string[]
+ nodeArgs?: string[]
+ peertubeArgs?: string[]
}
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
silent: true,
env,
detached: true,
- execArgv: options.execArgv || []
+ execArgv: options.nodeArgs || []
}
return new Promise<void>(res => {
- this.app = fork(join(root(), 'dist', 'server.js'), args, forkOptions)
+ const self = this
+
+ this.app = fork(join(root(), 'dist', 'server.js'), options.peertubeArgs || [], forkOptions)
this.app.stdout.on('data', function onStdout (data) {
let dontContinue = false
const regexp = regexps[key]
const matches = data.toString().match(regexp)
if (matches !== null) {
- if (key === 'client_id') this.store.client.id = matches[1]
- else if (key === 'client_secret') this.store.client.secret = matches[1]
- else if (key === 'user_username') this.store.user.username = matches[1]
- else if (key === 'user_password') this.store.user.password = matches[1]
+ if (key === 'client_id') self.store.client.id = matches[1]
+ else if (key === 'client_secret') self.store.client.secret = matches[1]
+ else if (key === 'user_username') self.store.user.username = matches[1]
+ else if (key === 'user_password') self.store.user.password = matches[1]
}
}
if (options.hideLogs === false) {
console.log(data.toString())
} else {
- this.app.stdout.removeListener('data', onStdout)
+ self.app.stdout.removeListener('data', onStdout)
}
process.on('exit', () => {
try {
- process.kill(this.server.app.pid)
+ process.kill(self.app.pid)
} catch { /* empty */ }
})