"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",
import * as helmet from 'helmet'
import * as useragent from 'useragent'
import * as anonymize from 'ip-anonymize'
+import * as cli from 'commander'
process.title = 'peertube'
// ----------- Command line -----------
+cli
+ .option('--no-client', 'Start PeerTube without client interface')
+ .parse(process.argv)
+
// ----------- App -----------
// Enable CORS for develop
app.use('/', staticRouter)
// Client files, last valid routes!
-app.use('/', clientsRouter)
+if (cli.client) app.use('/', clientsRouter)
// ----------- Errors -----------
import './reverse-proxy'
import './stats'
import './tracker'
+import './no-client'
--- /dev/null
+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()
+ }
+ })
+})
})
}
-function runServer (serverNumber: number, configOverride?: Object) {
+function runServer (serverNumber: number, configOverride?: Object, args = []) {
const server: ServerInfo = {
app: null,
serverNumber: serverNumber,
}
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