aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--package.json1
-rw-r--r--server.ts7
-rw-r--r--server/tests/api/server/index.ts1
-rw-r--r--server/tests/api/server/no-client.ts36
-rw-r--r--server/tests/utils/server/servers.ts4
5 files changed, 46 insertions, 3 deletions
diff --git a/package.json b/package.json
index 3c77b93cb..3d25a9ab8 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,7 @@
43 "dev:server": "scripty", 43 "dev:server": "scripty",
44 "dev:client": "scripty", 44 "dev:client": "scripty",
45 "start": "node dist/server", 45 "start": "node dist/server",
46 "start:server": "node dist/server --no-client",
46 "update-host": "node ./dist/scripts/update-host.js", 47 "update-host": "node ./dist/scripts/update-host.js",
47 "create-transcoding-job": "node ./dist/scripts/create-transcoding-job.js", 48 "create-transcoding-job": "node ./dist/scripts/create-transcoding-job.js",
48 "create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js", 49 "create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js",
diff --git a/server.ts b/server.ts
index 59fb820b4..51aa67638 100644
--- a/server.ts
+++ b/server.ts
@@ -16,6 +16,7 @@ import * as cookieParser from 'cookie-parser'
16import * as helmet from 'helmet' 16import * as helmet from 'helmet'
17import * as useragent from 'useragent' 17import * as useragent from 'useragent'
18import * as anonymize from 'ip-anonymize' 18import * as anonymize from 'ip-anonymize'
19import * as cli from 'commander'
19 20
20process.title = 'peertube' 21process.title = 'peertube'
21 22
@@ -98,6 +99,10 @@ import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redund
98 99
99// ----------- Command line ----------- 100// ----------- Command line -----------
100 101
102cli
103 .option('--no-client', 'Start PeerTube without client interface')
104 .parse(process.argv)
105
101// ----------- App ----------- 106// ----------- App -----------
102 107
103// Enable CORS for develop 108// Enable CORS for develop
@@ -151,7 +156,7 @@ app.use('/', trackerRouter)
151app.use('/', staticRouter) 156app.use('/', staticRouter)
152 157
153// Client files, last valid routes! 158// Client files, last valid routes!
154app.use('/', clientsRouter) 159if (cli.client) app.use('/', clientsRouter)
155 160
156// ----------- Errors ----------- 161// ----------- Errors -----------
157 162
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts
index eeb8b7a28..78ab7e18b 100644
--- a/server/tests/api/server/index.ts
+++ b/server/tests/api/server/index.ts
@@ -6,3 +6,4 @@ import './jobs'
6import './reverse-proxy' 6import './reverse-proxy'
7import './stats' 7import './stats'
8import './tracker' 8import './tracker'
9import './no-client'
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts
new file mode 100644
index 000000000..6d6ce8532
--- /dev/null
+++ b/server/tests/api/server/no-client.ts
@@ -0,0 +1,36 @@
1import 'mocha'
2import * as request from 'supertest'
3import {
4 flushTests,
5 killallServers,
6 ServerInfo
7} from '../../utils/index'
8import { runServer } from '../../utils/server/servers'
9
10describe('Start and stop server without web client routes', function () {
11 let server: ServerInfo
12
13 before(async function () {
14 this.timeout(30000)
15
16 await flushTests()
17
18 server = await runServer(1, {}, ['--no-client'])
19 })
20
21 it('Should fail getting the client', function () {
22 const req = request(server.url)
23 .get('/')
24
25 return req.expect(404)
26 })
27
28 after(async function () {
29 killallServers([ server ])
30
31 // Keep the logs if the test failed
32 if (this['ok']) {
33 await flushTests()
34 }
35 })
36})
diff --git a/server/tests/utils/server/servers.ts b/server/tests/utils/server/servers.ts
index 3c946db27..f358a21f1 100644
--- a/server/tests/utils/server/servers.ts
+++ b/server/tests/utils/server/servers.ts
@@ -69,7 +69,7 @@ function flushTests () {
69 }) 69 })
70} 70}
71 71
72function runServer (serverNumber: number, configOverride?: Object) { 72function runServer (serverNumber: number, configOverride?: Object, args = []) {
73 const server: ServerInfo = { 73 const server: ServerInfo = {
74 app: null, 74 app: null,
75 serverNumber: serverNumber, 75 serverNumber: serverNumber,
@@ -115,7 +115,7 @@ function runServer (serverNumber: number, configOverride?: Object) {
115 } 115 }
116 116
117 return new Promise<ServerInfo>(res => { 117 return new Promise<ServerInfo>(res => {
118 server.app = fork(join(__dirname, '..', '..', '..', '..', 'dist', 'server.js'), [], options) 118 server.app = fork(join(__dirname, '..', '..', '..', '..', 'dist', 'server.js'), args, options)
119 server.app.stdout.on('data', function onStdout (data) { 119 server.app.stdout.on('data', function onStdout (data) {
120 let dontContinue = false 120 let dontContinue = false
121 121