add cli option to run without client
This commit is contained in:
parent
fb651cf2d4
commit
b83b8dd5ae
5 changed files with 46 additions and 3 deletions
|
@ -43,6 +43,7 @@
|
|||
"dev:server": "scripty",
|
||||
"dev:client": "scripty",
|
||||
"start": "node dist/server",
|
||||
"start:server": "node dist/server --no-client",
|
||||
"update-host": "node ./dist/scripts/update-host.js",
|
||||
"create-transcoding-job": "node ./dist/scripts/create-transcoding-job.js",
|
||||
"create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js",
|
||||
|
|
|
@ -16,6 +16,7 @@ import * as cookieParser from 'cookie-parser'
|
|||
import * as helmet from 'helmet'
|
||||
import * as useragent from 'useragent'
|
||||
import * as anonymize from 'ip-anonymize'
|
||||
import * as cli from 'commander'
|
||||
|
||||
process.title = 'peertube'
|
||||
|
||||
|
@ -98,6 +99,10 @@ import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redund
|
|||
|
||||
// ----------- Command line -----------
|
||||
|
||||
cli
|
||||
.option('--no-client', 'Start PeerTube without client interface')
|
||||
.parse(process.argv)
|
||||
|
||||
// ----------- App -----------
|
||||
|
||||
// Enable CORS for develop
|
||||
|
@ -151,7 +156,7 @@ app.use('/', trackerRouter)
|
|||
app.use('/', staticRouter)
|
||||
|
||||
// Client files, last valid routes!
|
||||
app.use('/', clientsRouter)
|
||||
if (cli.client) app.use('/', clientsRouter)
|
||||
|
||||
// ----------- Errors -----------
|
||||
|
||||
|
|
|
@ -6,3 +6,4 @@ import './jobs'
|
|||
import './reverse-proxy'
|
||||
import './stats'
|
||||
import './tracker'
|
||||
import './no-client'
|
||||
|
|
36
server/tests/api/server/no-client.ts
Normal file
36
server/tests/api/server/no-client.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import 'mocha'
|
||||
import * as request from 'supertest'
|
||||
import {
|
||||
flushTests,
|
||||
killallServers,
|
||||
ServerInfo
|
||||
} from '../../utils/index'
|
||||
import { runServer } from '../../utils/server/servers'
|
||||
|
||||
describe('Start and stop server without web client routes', function () {
|
||||
let server: ServerInfo
|
||||
|
||||
before(async function () {
|
||||
this.timeout(30000)
|
||||
|
||||
await flushTests()
|
||||
|
||||
server = await runServer(1, {}, ['--no-client'])
|
||||
})
|
||||
|
||||
it('Should fail getting the client', function () {
|
||||
const req = request(server.url)
|
||||
.get('/')
|
||||
|
||||
return req.expect(404)
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
killallServers([ server ])
|
||||
|
||||
// Keep the logs if the test failed
|
||||
if (this['ok']) {
|
||||
await flushTests()
|
||||
}
|
||||
})
|
||||
})
|
|
@ -69,7 +69,7 @@ function flushTests () {
|
|||
})
|
||||
}
|
||||
|
||||
function runServer (serverNumber: number, configOverride?: Object) {
|
||||
function runServer (serverNumber: number, configOverride?: Object, args = []) {
|
||||
const server: ServerInfo = {
|
||||
app: null,
|
||||
serverNumber: serverNumber,
|
||||
|
@ -115,7 +115,7 @@ function runServer (serverNumber: number, configOverride?: Object) {
|
|||
}
|
||||
|
||||
return new Promise<ServerInfo>(res => {
|
||||
server.app = fork(join(__dirname, '..', '..', '..', '..', 'dist', 'server.js'), [], options)
|
||||
server.app = fork(join(__dirname, '..', '..', '..', '..', 'dist', 'server.js'), args, options)
|
||||
server.app.stdout.on('data', function onStdout (data) {
|
||||
let dontContinue = false
|
||||
|
||||
|
|
Loading…
Reference in a new issue