diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-11-14 15:27:47 +0100 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2018-11-14 15:59:56 +0100 |
commit | b83b8dd5aef03084133c5983de6f312e7d1654b8 (patch) | |
tree | 4daf0f5f10dac8b1c5704d9823b734aa1051d99a | |
parent | fb651cf2d426e7429a7c571ab7d93becd63ad116 (diff) | |
download | PeerTube-b83b8dd5aef03084133c5983de6f312e7d1654b8.tar.gz PeerTube-b83b8dd5aef03084133c5983de6f312e7d1654b8.tar.zst PeerTube-b83b8dd5aef03084133c5983de6f312e7d1654b8.zip |
add cli option to run without client
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | server.ts | 7 | ||||
-rw-r--r-- | server/tests/api/server/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/server/no-client.ts | 36 | ||||
-rw-r--r-- | server/tests/utils/server/servers.ts | 4 |
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", |
@@ -16,6 +16,7 @@ import * as cookieParser from 'cookie-parser' | |||
16 | import * as helmet from 'helmet' | 16 | import * as helmet from 'helmet' |
17 | import * as useragent from 'useragent' | 17 | import * as useragent from 'useragent' |
18 | import * as anonymize from 'ip-anonymize' | 18 | import * as anonymize from 'ip-anonymize' |
19 | import * as cli from 'commander' | ||
19 | 20 | ||
20 | process.title = 'peertube' | 21 | process.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 | ||
102 | cli | ||
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) | |||
151 | app.use('/', staticRouter) | 156 | app.use('/', staticRouter) |
152 | 157 | ||
153 | // Client files, last valid routes! | 158 | // Client files, last valid routes! |
154 | app.use('/', clientsRouter) | 159 | if (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' | |||
6 | import './reverse-proxy' | 6 | import './reverse-proxy' |
7 | import './stats' | 7 | import './stats' |
8 | import './tracker' | 8 | import './tracker' |
9 | import './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 @@ | |||
1 | import 'mocha' | ||
2 | import * as request from 'supertest' | ||
3 | import { | ||
4 | flushTests, | ||
5 | killallServers, | ||
6 | ServerInfo | ||
7 | } from '../../utils/index' | ||
8 | import { runServer } from '../../utils/server/servers' | ||
9 | |||
10 | describe('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 | ||
72 | function runServer (serverNumber: number, configOverride?: Object) { | 72 | function 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 | ||