aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-12 18:07:41 +0100
committerChocobozzz <me@florianbigard.com>2018-01-12 18:07:41 +0100
commit63bfad7ec984dad1e9a96de1f191db5cc78db5bf (patch)
treefe003158afa1ab6795652ae114c08be580078efb
parent339632b4a3f94a6ebee3767054ef6c701858a785 (diff)
downloadPeerTube-63bfad7ec984dad1e9a96de1f191db5cc78db5bf.tar.gz
PeerTube-63bfad7ec984dad1e9a96de1f191db5cc78db5bf.tar.zst
PeerTube-63bfad7ec984dad1e9a96de1f191db5cc78db5bf.zip
Try to improve documentations/readme
-rw-r--r--.github/CONTRIBUTING.md77
-rw-r--r--.github/ISSUE_TEMPLATE.md25
-rw-r--r--ARCHITECTURE.md2
-rw-r--r--FAQ.md4
-rw-r--r--README.md150
-rw-r--r--package.json1
-rwxr-xr-xscripts/check.ts171
-rw-r--r--support/doc/dependencies.md29
-rw-r--r--support/doc/development/client/code.md7
-rw-r--r--support/doc/development/server/code.md15
-rw-r--r--support/doc/production.md227
-rw-r--r--support/systemd/peertube.service1
12 files changed, 335 insertions, 374 deletions
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 989087728..dec6a5cd0 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -1,14 +1,12 @@
1# Welcome to the contributing guide for PeerTube 1# Welcome to the contributing guide for PeerTube
2 2
3Interesting in contributing? Awesome :) 3Interesting in contributing? Awesome!
4 4
5**Quick Links:** 5**Quick Links:**
6 6
7 * [Give your feedback](#give-your-feedback) 7 * [Give your feedback](#give-your-feedback)
8 * [Develop on the Server side](#develop-on-the-server-side)
9 * [Develop on the Client side](#develop-on-the-client-side)
10 * [Get started with development](#get-started-with-development)
11 * [Write documentation](#write-documentation) 8 * [Write documentation](#write-documentation)
9 * [Develop](#develop)
12 10
13 11
14## Give your feedback 12## Give your feedback
@@ -16,40 +14,32 @@ Interesting in contributing? Awesome :)
16You don't need to know how to code to start contributing to PeerTube! Other 14You don't need to know how to code to start contributing to PeerTube! Other
17contributions are very valuable too, among which: you can test the software and 15contributions are very valuable too, among which: you can test the software and
18report bugs, you can give feedback on potential bugs, features that you are 16report bugs, you can give feedback on potential bugs, features that you are
19interested in, user interace, design, decentralized architecture... 17interested in, user interface, design, decentralized architecture...
20 18
21 19
22## Development 20## Write documentation
23
24## Develop on the Server side
25 21
26The server is a web server developed with 22You can help to write the documentation of the REST API, code, architecture,
27[NodeJS](https://nodejs.org)/[Express](http://expressjs.com). 23demonstrations...
28 24
29Newcomer? You can find a documentation of the server code/architecture 25## Develop
30[here](https://github.com/Chocobozzz/PeerTube/blob/master/support/doc/server/code.md).
31 26
32Don't hesitate to talk about features you want to develop by creating an issue 27Don't hesitate to talk about features you want to develop by creating an issue
33before you start working on them :). 28before you start working on them :).
34 29
30### Prerequisites
35 31
36## Develop on the Client side 32First, make sure that you have followed
37 33[the steps](/support/doc/dependencies.md)
38The client is a web application developed with 34to install the dependencies.
39[TypeScript](https://www.typescriptlang.org/)/[Angular2](https://angular.io/).
40
41Newcomer? You can find a documentation of the server code/architecture
42[here](https://github.com/Chocobozzz/PeerTube/blob/master/support/doc/client/code.md).
43
44
45## Get started with development
46
47In this mode, the server will run requests between instances more quickly, the
48video durations are limited to a few seconds.
49 35
50### Prerequisites 36Then clone the sources and install node modules:
51 37
52First, make sure that you have followed the steps to install the dependencies. 38```bash
39$ git clone -b master https://github.com/Chocobozzz/PeerTube
40$ cd PeerTube
41$ yarn install --pure-lockfile
42```
53 43
54Then, create a postgres database and user with the values set in the 44Then, create a postgres database and user with the values set in the
55`config/default.yaml` file. For instance, if you do not change the values 45`config/default.yaml` file. For instance, if you do not change the values
@@ -57,40 +47,51 @@ there, the following commands would create a new database called `peertube_dev`
57and a postgres user called `peertube` with password `peertube`: 47and a postgres user called `peertube` with password `peertube`:
58 48
59```bash 49```bash
60 # sudo -u postgres createuser -P peertube 50# sudo -u postgres createuser -P peertube
61 Enter password for new role: peertube 51Enter password for new role: peertube
62 # sudo -u postgres createdb -O peertube peertube_dev 52# sudo -u postgres createdb -O peertube peertube_dev
63``` 53```
64 54
55In dev mode, administrator username is **root** and password is **test**.
56
65### Server side 57### Server side
66 58
59You can find a documentation of the server code/architecture [here](/support/doc/development/server/code.md).
60
67To develop on the server-side: 61To develop on the server-side:
68 62
69```bash 63```bash
70 $ npm run dev:server 64$ npm run dev:server
71``` 65```
72 66
73Then, the server will listen on `localhost:9000`. When server source files 67Then, the server will listen on `localhost:9000`. When server source files
74change, these are automatically recompiled and the server will automatically 68change, these are automatically recompiled and the server will automatically
75restart. 69restart. Server is in `TEST` mode so it will run requests between instances more quickly.
76 70
77### Client side 71### Client side
78 72
73You can find a documentation of the server code/architecture
74[here](/support/doc/development/client/code.md).
75
76
79To develop on the client side: 77To develop on the client side:
80 78
81```bash 79```bash
82 $ npm run dev:client 80$ npm run dev:client
83``` 81```
84 82
85The API will listen on `localhost:9000` and the frontend on `localhost:3000`. 83The API will listen on `localhost:9000` and the frontend on `localhost:3000`.
86Client files are automatically compiled on change, and the web browser will 84Client files are automatically compiled on change, and the web browser will
87reload them automatically thanks to hot module replacement. 85reload them automatically thanks to hot module replacement.
88 86
89**Username**: *root* <br/> 87### Test federation
90**Password**: *test*
91 88
89This will run 3 nodes:
92 90
93## Write documentation 91```bash
92$ npm run clean:server:test
93$ npm run play
94```
94 95
95You can help to write the documentation of the REST API, code, architecture, 96Then you will get access to the three nodes at `http://localhost:900{1,2,3}`
96demonstrations... 97with the `root` as username and `test{1,2,3}` for the password.
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 74ea70939..c6f2dd064 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,10 +1,15 @@
1<!-- 1<!-- If you report a bug please fill the form -->
2 Problem with the demonstration server? 2
3 -> Please retry in a few hours or send me directly an email: https://github.com/Chocobozzz 3* **PeerTube version or commit:**
4 Bug? 4* **Browser name/version:**
5 -> Please check first you're running on the latest version of Firefox/Chromium 5* **NodeJS version:**
6 -> Please check the console log to add informations to the bug report 6* **PostgreSQL version:**
7--> 7
8 8
9* Browser name/version: 9* **What is the expected behaviour?**
10* Console log if useful (Gist/Pastebin...): 10* **What do you see instead?**
11
12
13* **Browser console log if useful (Gist/Pastebin...):**
14* **Server log if useful (Gist/Pastebin...):**
15
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index cf0dcfacd..160d6fc4f 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -18,7 +18,7 @@
18 * We use the [ActivityPub](https://www.w3.org/TR/activitypub/) protocol (only 18 * We use the [ActivityPub](https://www.w3.org/TR/activitypub/) protocol (only
19 server-server for now). Object models could be found in 19 server-server for now). Object models could be found in
20 [shared/models/activitypub 20 [shared/models/activitypub
21 directory](https://github.com/Chocobozzz/PeerTube/tree/develop/shared/models/activitypub). 21 directory](/shared/models/activitypub).
22 * All the requests are retried several times if they fail. 22 * All the requests are retried several times if they fail.
23 23
24### Instance 24### Instance
diff --git a/FAQ.md b/FAQ.md
index 06c86ce10..1bcd6006a 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -31,9 +31,9 @@ We think it is acceptable for a video platform.
31WEBM, MP4 or OGV videos. 31WEBM, MP4 or OGV videos.
32 32
33 33
34## I want to change my host or move to HTTPS, how can I do that? 34## I want to change my host, how can I do that?
35 35
36If you already have followers, you can't. 36If you already have followers, you can't.
37 37
38If you don't have any followers, update your configuration and run 38If you don't have any followers, update your configuration and run
39`NODE_ENV=production npm run update-host` to update the torrent files. 39`NODE_ENV=production npm run update-host` to update the torrent files (they contain your domain name).
diff --git a/README.md b/README.md
index 094d81c4a..7972fbed8 100644
--- a/README.md
+++ b/README.md
@@ -64,13 +64,12 @@ donating them](https://soutenir.framasoft.org/en/).**
64 64
65Want to see it in action? 65Want to see it in action?
66 66
67 * [Demo server](http://peertube.cpy.re) 67 * Demonstration servers:
68 * [peertube.cpy.re](http://peertube.cpy.re)
69 * [peertube2.cpy.re](http://peertube2.cpy.re)
70 * [peertube3.cpy.re](http://peertube3.cpy.re)
68 * [Video](https://peertube.cpy.re/videos/watch/f78a97f8-a142-4ce1-a5bd-154bf9386504) 71 * [Video](https://peertube.cpy.re/videos/watch/f78a97f8-a142-4ce1-a5bd-154bf9386504)
69 to see how the "decentralization feature" looks like 72 to see how the "decentralization feature" looks like
70 * Experimental demo servers that share videos (they are in the same
71 network): [peertube2](http://peertube2.cpy.re),
72 [peertube3](http://peertube3.cpy.re). Since I do experiments with them,
73 sometimes they might not work correctly.
74 73
75## Why 74## Why
76 75
@@ -83,12 +82,11 @@ So we need to have a decentralized network of servers seeding videos (as
83enough because one video could become famous and overload the server. It's the 82enough because one video could become famous and overload the server. It's the
84reason why we need to use a P2P protocol to limit the server load. Thanks to 83reason why we need to use a P2P protocol to limit the server load. Thanks to
85[WebTorrent](https://github.com/feross/webtorrent), we can make P2P (thus 84[WebTorrent](https://github.com/feross/webtorrent), we can make P2P (thus
86bittorrent) inside the web browser, as of today. 85BitTorrent) inside the web browser, as of today.
87 86
88## Features 87## Features
89 88
90- [X] Frontend 89- [X] Angular frontend
91 - [X] Angular frontend
92- [X] Join the fediverse 90- [X] Join the fediverse
93 - [X] Follow other instances 91 - [X] Follow other instances
94 - [X] Unfollow an instance 92 - [X] Unfollow an instance
@@ -103,8 +101,8 @@ bittorrent) inside the web browser, as of today.
103- [X] OpenGraph tags 101- [X] OpenGraph tags
104- [X] OEmbed 102- [X] OEmbed
105- [X] Update video 103- [X] Update video
106- [X] Videos view counter 104- [X] Federated videos view counter
107- [X] Videos likes/dislikes 105- [X] Federated videos likes/dislikes
108- [X] Transcoding to different definitions 106- [X] Transcoding to different definitions
109- [X] Download file/torrent 107- [X] Download file/torrent
110- [X] User video bytes quota 108- [X] User video bytes quota
@@ -115,140 +113,32 @@ bittorrent) inside the web browser, as of today.
115- [X] User registration 113- [X] User registration
116- [X] Video privacy settings (public, unlisted or private) 114- [X] Video privacy settings (public, unlisted or private)
117- [X] Signaling a video to the admin origin PeerTube instance 115- [X] Signaling a video to the admin origin PeerTube instance
118- [ ] Videos comments 116- [X] Federated videos comments
117- [ ] Video imports (URL, Torrent, YouTube...)
118- [ ] Advanced search
119- [ ] Subtitles
119- [ ] User playlist 120- [ ] User playlist
120- [ ] User subscriptions (by tags, author...) 121- [ ] User subscriptions (by tags, author...)
121- [ ] Add "DDOS" security 122- [ ] Add "DDOS" security
122 123
123 124
124## Installation 125## Front compatibility
125 126
126See [wiki](https://github.com/Chocobozzz/PeerTube/wiki) for complete 127 * Firefox
127installation commands. 128 * Chrome/Chromium
128 129
129### Front compatibility 130## Dependencies
130
131 * Chromium
132 * Firefox (>= 42 for MediaSource support)
133
134### Dependencies
135 131
132 * nginx
133 * PostgreSQL
136 * **NodeJS >= 8.x** 134 * **NodeJS >= 8.x**
137 * yarn 135 * yarn
138 * OpenSSL (cli) 136 * OpenSSL (cli)
139 * PostgreSQL
140 * FFmpeg 137 * FFmpeg
141 138
142#### Debian 139## Production
143
144 1. Install NodeJS 8.x (current LTS):
145 [https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions)
146 2. Install yarn:
147 [https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install)
148 4. Run:
149
150```bash
151 $ apt-get update
152 $ apt-get install ffmpeg postgresql openssl
153```
154
155#### Ubuntu 16.04
156
157 1. Install NodeJS 8.x (current LTS): (same as Debian)
158 2. Install yarn: (same as Debian)
159 3. Run:
160
161```bash
162 $ apt-get update
163 $ apt-get install ffmpeg postgresql openssl
164```
165
166#### Arch Linux
167
168 1. Run:
169
170```bash
171 $ pacman -S nodejs yarn ffmpeg postgresql openssl
172```
173
174#### Other distributions
175
176Feel free to update this README file in a pull request!
177
178### Build from the sources
179
180```bash
181 $ git clone -b master https://github.com/Chocobozzz/PeerTube
182 $ cd PeerTube
183 $ yarn install
184 $ npm run build
185```
186
187## Usage
188
189### Production
190
191If you want to run PeerTube in production (which might be a bad idea for now :) ):
192
193```bash
194 $ cp config/production.yaml.example config/production.yaml
195```
196
197Then edit the `config/production.yaml` file according to your webserver
198configuration. Keys set in this file will override those of
199`config/default.yml`.
200
201Finally, run the server with the `NODE_ENV` environment variable set to
202`production`:
203
204```bash
205 $ NODE_ENV=production npm start
206```
207
208The administrator password is automatically generated and can be found in the
209logs. You can set another password with:
210
211```bash
212 $ NODE_ENV=production npm run reset-password -- -u root
213```
214
215**Nginx template** (reverse proxy): https://github.com/Chocobozzz/PeerTube/tree/master/support/nginx <br />
216**Systemd template**: https://github.com/Chocobozzz/PeerTube/tree/master/support/systemd
217
218You can check the application (CORS headers, tracker websocket...) by running:
219
220```bash
221 $ NODE_ENV=production npm run check
222```
223
224### Upgrade
225
226The following commands will upgrade the source (according to your current
227branch), upgrade node modules and rebuild client application:
228
229```bash
230 # systemctl stop peertube
231 $ npm run upgrade-peertube
232 # systemctl start peertube
233```
234
235### Test with three fresh nodes
236
237```bash
238 $ npm run clean:server:test
239 $ npm run play
240```
241
242Then you will get access to the three nodes at `http://localhost:900{1,2,3}`
243with the `root` as username and `test{1,2,3}` for the password.
244
245### Other commands
246
247To print all available commands, run:
248 140
249```bash 141See the [production guide](support/doc/production.md).
250 $ npm run help
251```
252 142
253## Contributing 143## Contributing
254 144
diff --git a/package.json b/package.json
index 8f72daa4d..efe03dc04 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,6 @@
34 "dev:server": "scripty", 34 "dev:server": "scripty",
35 "dev:client": "scripty", 35 "dev:client": "scripty",
36 "start": "node dist/server", 36 "start": "node dist/server",
37 "check": "ts-node ./scripts/check.ts",
38 "upgrade-peertube": "scripty", 37 "upgrade-peertube": "scripty",
39 "upgrade": "echo 'This command was renamed to upgrade-peertube.'", 38 "upgrade": "echo 'This command was renamed to upgrade-peertube.'",
40 "update-host": "ts-node ./scripts/update-host.ts", 39 "update-host": "ts-node ./scripts/update-host.ts",
diff --git a/scripts/check.ts b/scripts/check.ts
deleted file mode 100755
index 24f4806af..000000000
--- a/scripts/check.ts
+++ /dev/null
@@ -1,171 +0,0 @@
1import * as series from 'async/series'
2import * as request from 'request'
3import * as WebSocket from 'ws'
4
5import { CONFIG } from '../server/initializers/constants'
6
7const requestHeaders = {
8 'Range': '',
9 'Keep-Alive': '',
10 'User-Agent': 'Mozilla',
11 'Cache-Control': 'no-cache',
12 'Content-Type': '',
13 'Host': 'example.com',
14 'Access-Control-Request-Method': 'GET',
15 'Access-Control-Request-Headers': 'range'
16}
17
18series([
19 pingServer,
20 checkCORSTorrent,
21 checkCORSWebSeed,
22 checkTracker
23], function () {
24 process.exit(0)
25})
26
27// ---------------------------------------------------------------------------
28
29function pingServer (callback: () => void) {
30 const pingUrl = CONFIG.WEBSERVER.URL + '/api/v1/ping'
31 console.log('Checking server is up (%s)...', pingUrl)
32
33 request(pingUrl, function (err, res, body) {
34 if (!err && res.statusCode === 200 && body === 'pong') {
35 console.log('SUCCESS.')
36 } else {
37 console.log('FAIL.')
38 }
39
40 callback()
41 })
42}
43
44function checkCORSTorrent (callback: () => void) {
45 const torrentUrl = CONFIG.WEBSERVER.URL + '/static/torrents/test.torrent'
46 console.log('Checking CORS headers for the torrent (%s)...', torrentUrl)
47
48 request({
49 method: 'OPTIONS',
50 uri: torrentUrl,
51 headers: requestHeaders
52 }, function (err, res) {
53 if (err || isThereValidCORSHeaders(res) === false) {
54 console.error('FAIL.')
55 } else {
56 console.log('SUCCESS.')
57 }
58
59 callback()
60 })
61}
62
63function checkCORSWebSeed (callback: () => void) {
64 const webseedUrl = CONFIG.WEBSERVER.URL + '/static/webseed/test.mp4'
65 console.log('Checking CORS headers for the video (%s)...', webseedUrl)
66
67 request({
68 method: 'OPTIONS',
69 uri: webseedUrl,
70 headers: requestHeaders
71 }, function (err, res) {
72 if (err || isThereValidCORSHeaders(res) === false) {
73 console.error('FAIL.')
74 } else {
75 console.log('SUCCESS.')
76 }
77
78 callback()
79 })
80}
81
82function checkTracker (callback: () => void) {
83 const trackerUrl = CONFIG.WEBSERVER.WS + '://' +
84 CONFIG.WEBSERVER.HOST +
85 '/tracker/socket'
86 console.log('Checking tracker websocket (%s)...', trackerUrl)
87
88 let ws = null
89 ws = new WebSocket(trackerUrl)
90
91 const timeout = setTimeout(failed, 1000)
92 ws.on('open', onOpen)
93
94 function onOpen () {
95 clearTimeout(timeout)
96 ws.close()
97
98 console.log('SUCCESS.')
99 callback()
100 }
101
102 function failed () {
103 ws.removeListener('open', onOpen)
104 ws.close()
105
106 console.log('FAILED.')
107 callback()
108 }
109}
110
111function isThereValidCORSHeaders (res: request.RequestResponse) {
112 let fail = false
113
114 // Check Access-Control-Allow-Origin
115 const headerAllowOriginKey = 'access-control-allow-origin'
116 const headerAllowOrigin = res.headers[headerAllowOriginKey]
117
118 if (!headerAllowOrigin) {
119 console.error(headerAllowOriginKey + ' is not present.')
120 fail = true
121 } else if (headerAllowOrigin !== '*') {
122 console.error(headerAllowOriginKey + ' does not equal "*".')
123 fail = true
124 }
125
126 // Check Access-Control-Allow-Methods
127 const headerAllowMethodsKey = 'access-control-allow-methods'
128 const headerAllowMethods = res.headers[headerAllowMethodsKey]
129 if (!headerAllowMethods) {
130 console.error(headerAllowMethodsKey + ' is not present.')
131 fail = true
132 } else {
133 const allowMethodsMissed = findPatternNotInString(headerAllowMethods as string, [ 'get' ])
134 if (allowMethodsMissed !== null) {
135 console.error(headerAllowMethodsKey + ' misses the ' + allowMethodsMissed + ' method.')
136 fail = true
137 }
138 }
139
140 // Check Access-Control-Allow-Headers
141 const headerAllowHeadersKey = 'access-control-allow-headers'
142 const headerAllowHeaders = res.headers[headerAllowHeadersKey]
143 if (!headerAllowHeaders) {
144 console.error(headerAllowHeadersKey + ' is not present.')
145 fail = true
146 } else {
147 const headersThatShouldBePresent = [
148 'Range'
149 ]
150 const allowHeadersMissed = findPatternNotInString(headerAllowHeaders as string, headersThatShouldBePresent)
151 if (allowHeadersMissed !== null) {
152 console.error(headerAllowHeadersKey + ' misses the ' + allowHeadersMissed + ' header.')
153 fail = true
154 }
155 }
156
157 return !fail
158}
159
160function findPatternNotInString (stringChain: string, patterns: string[]) {
161 let res = null
162 const stringChainLowerCase = stringChain.toLowerCase()
163
164 patterns.forEach(function (pattern) {
165 if (stringChainLowerCase.indexOf(pattern.toLowerCase()) === -1) {
166 res = pattern
167 }
168 })
169
170 return res
171}
diff --git a/support/doc/dependencies.md b/support/doc/dependencies.md
new file mode 100644
index 000000000..d77724b5a
--- /dev/null
+++ b/support/doc/dependencies.md
@@ -0,0 +1,29 @@
1# Installation
2
3## Dependencies
4
5### Debian / Ubuntu
6
7 1. Install NodeJS 8.x (current LTS):
8 [https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions)
9 2. Install yarn:
10 [https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install)
11 4. Run:
12
13```bash
14$ apt-get update
15$ apt-get install nginx ffmpeg postgresql openssl g++ make
16```
17
18### Arch Linux
19
20 1. Run:
21
22```bash
23$ pacman -S nodejs yarn ffmpeg postgresql openssl
24```
25
26### Other distributions
27
28Feel free to update this file in a pull request!
29
diff --git a/support/doc/development/client/code.md b/support/doc/development/client/code.md
index ddd277e54..749783c29 100644
--- a/support/doc/development/client/code.md
+++ b/support/doc/development/client/code.md
@@ -53,12 +53,7 @@ Details of the Angular application file structure. It tries to follow [the offic
53 53
54Uses [TSLint](https://palantir.github.io/tslint/) for TypeScript linting and [Angular styleguide](https://angular.io/docs/ts/latest/guide/style-guide.html). 54Uses [TSLint](https://palantir.github.io/tslint/) for TypeScript linting and [Angular styleguide](https://angular.io/docs/ts/latest/guide/style-guide.html).
55 55
56## Developing 56## Concepts
57
58 * Install [the dependencies](https://github.com/Chocobozzz/PeerTube#dependencies)
59 * Run `yarn install --pure-lockfile` at the root directory to install all the dependencies
60 * Run PostgreSQL and create the database `peertube_dev`.
61 * Run `npm run dev:client` to compile the client, run the server, watch client files modifications and reload modules on the fly (you don't need to refresh manually the web browser). The API listen on `localhost:9000` and the client on `localhost:3000`.
62 57
63In a Angular application, we create components that we put together. Each component is defined by an HTML structure, a TypeScript file and optionally a SASS file. 58In a Angular application, we create components that we put together. Each component is defined by an HTML structure, a TypeScript file and optionally a SASS file.
64If you are not familiar with Angular I recommend you to read the [quickstart guide](https://angular.io/docs/ts/latest/quickstart.html). 59If you are not familiar with Angular I recommend you to read the [quickstart guide](https://angular.io/docs/ts/latest/quickstart.html).
diff --git a/support/doc/development/server/code.md b/support/doc/development/server/code.md
index d909b0c3d..ddb93119b 100644
--- a/support/doc/development/server/code.md
+++ b/support/doc/development/server/code.md
@@ -36,21 +36,6 @@ All other server files are in the [server](https://github.com/Chocobozzz/PeerTub
36 36
37Uses [JavaScript Standard Style](http://standardjs.com/). 37Uses [JavaScript Standard Style](http://standardjs.com/).
38 38
39
40## Developing
41
42 * Install [the dependencies](https://github.com/Chocobozzz/PeerTube#dependencies)
43 * Run `yarn install` at the root directory to install all the dependencies
44 * Run PostgreSQL and create the database `peertube_dev`.
45 * Run `npm run dev:server` to run the server, watch server files modifications and restart it automatically. The server (API + client) listen on `localhost:9000`.
46
47The `NODE_ENV=test` is set to speed up communications between instances (see [constants.ts](https://github.com/Chocobozzz/PeerTube/blob/master/server/initializers/constants.ts)).
48
49`npm run help` gives you all available commands.
50
51If you want to test the decentralization feature, you can easily run 3 instances by running `npm run play`. The instances password are `test1`, `test2` and `test3`.
52
53
54## Architecture 39## Architecture
55 40
56The server is composed by: 41The server is composed by:
diff --git a/support/doc/production.md b/support/doc/production.md
new file mode 100644
index 000000000..4d7c14f2b
--- /dev/null
+++ b/support/doc/production.md
@@ -0,0 +1,227 @@
1# Production guide
2
3## Installation
4
5### Dependencies
6
7Follow the steps of the [dependencies guide](dependencies.md).
8
9### PeerTube user
10
11Create a `peertube` user with `/home/peertube` home:
12
13```bash
14sudo useradd -m -d /home/peertube -s /bin/bash -p peertube peertube
15sudo passwd peertube
16```
17
18### Database
19
20Create production database and peertube user:
21
22```bash
23sudo -u postgres createuser -P peertube
24sudo -u postgres createdb -O peertube peertube_prod
25```
26
27### Sources
28
29Clone, install node dependencies and build application:
30
31```bash
32$ cd /home/peertube
33$ sudo -u peertube git clone -b master https://github.com/Chocobozzz/PeerTube
34$ cd PeerTube
35$ sudo -u peertube yarn install --pure-lockfile
36$ sudo -u peertube npm run build
37```
38
39### PeerTube configuration
40
41Copy example configuration:
42
43```bash
44$ sudo -u peertube cp config/production.yaml.example config/production.yaml
45```
46
47Then edit the `config/production.yaml` file according to your webserver
48configuration. Keys set in this file will override those of
49`config/default.yml`.
50
51### Webserver
52
53Copy the nginx configuration template:
54
55```bash
56$ sudo cp /home/peertube/PeerTube/support/nginx/peertube-https /etc/nginx/sites-available/peertube
57```
58
59Then modify the webserver configuration file. Please pay attention to the `alias` key of `/static/webseed` location.
60It should correspond to the path of your videos directory (set in the configuration file as `storage->videos` key).
61
62```bash
63$ sudo vim /etc/nginx/sites-available/peertube
64```
65
66If you want to set https with Let's Encrypt please follow the steps of [this guide](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04).
67
68An example of the nginx configuration could be:
69
70```
71server {
72 listen 80;
73 listen [::]:80;
74 server_name peertube.example.com;
75
76 access_log /var/log/nginx/peertube.example.com.access.log;
77 error_log /var/log/nginx/peertube.example.com.error.log;
78
79 rewrite ^ https://$server_name$request_uri? permanent;
80}
81
82server {
83 listen 443 ssl http2;
84 listen [::]:443 ssl http2;
85 server_name peertube.example.com;
86
87 # For example with Let's Encrypt
88 ssl_certificate /etc/letsencrypt/live/peertube.example.com/fullchain.pem;
89 ssl_certificate_key /etc/letsencrypt/live/peertube.example.com/privkey.pem;
90 ssl_trusted_certificate /etc/letsencrypt/live/peertube.example.com/chain.pem;
91
92 access_log /var/log/nginx/peertube.example.com.access.log;
93 error_log /var/log/nginx/peertube.example.com.error.log;
94
95 location ^~ '/.well-known/acme-challenge' {
96 default_type "text/plain";
97 root /var/www/certbot;
98 }
99
100 location / {
101 proxy_pass http://localhost:9000;
102 proxy_set_header X-Real-IP $remote_addr;
103 proxy_set_header Host $host;
104 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
105
106 # For the video upload
107 client_max_body_size 8G;
108 proxy_connect_timeout 600;
109 proxy_send_timeout 600;
110 proxy_read_timeout 600;
111 send_timeout 600;
112 }
113
114 # Bypass PeerTube webseed route for better performances
115 location /static/webseed {
116 if ($request_method = 'OPTIONS') {
117 add_header 'Access-Control-Allow-Origin' '*';
118 add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
119 add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
120 add_header 'Access-Control-Max-Age' 1728000;
121 add_header 'Content-Type' 'text/plain charset=UTF-8';
122 add_header 'Content-Length' 0;
123 return 204;
124 }
125
126 if ($request_method = 'GET') {
127 add_header 'Access-Control-Allow-Origin' '*';
128 add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
129 add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
130 }
131
132 alias /var/www/PeerTube/videos;
133 }
134
135 # Websocket tracker
136 location /tracker/socket {
137 # Peers send a message to the tracker every 15 minutes
138 # Don't close the websocket before this time
139 proxy_read_timeout 1200s;
140 proxy_set_header Upgrade $http_upgrade;
141 proxy_set_header Connection "upgrade";
142 proxy_http_version 1.1;
143 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
144 proxy_set_header Host $host;
145 proxy_pass http://localhost:9000;
146 }
147}
148```
149
150
151Activate the configuration file:
152
153```bash
154$ sudo ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/peertube
155$ sudo systemctl reload nginx
156```
157
158### Systemd
159
160Copy the nginx configuration template:
161
162```bash
163sudo cp /home/peertube/PeerTube/support/systemd/peertube.service /etc/systemd/system/
164```
165
166Update the service file:
167
168```bash
169sudo vim /etc/systemd/system/peertube.service
170```
171
172It should look like this:
173
174```
175[Unit]
176Description=PeerTube daemon
177After=network.target
178
179[Service]
180Type=simple
181Environment=NODE_ENV=production
182User=peertube
183Group=peertube
184ExecStart=/usr/bin/npm start
185WorkingDirectory=/home/peertube/PeerTube
186StandardOutput=syslog
187StandardError=syslog
188SyslogIdentifier=peertube
189Restart=always
190
191[Install]
192WantedBy=multi-user.target
193```
194
195
196Tell systemd to reload its config:
197
198```bash
199sudo systemctl daemon-reload
200```
201
202### Run
203
204```bash
205sudo systemctl start peertube
206sudo journalctl -feu peertube
207```
208
209### Administrator
210
211The administrator password is automatically generated and can be found in the
212logs. You can set another password with:
213
214```bash
215$ NODE_ENV=production npm run reset-password -- -u root
216```
217
218## Upgrade
219
220The following commands will upgrade the source (according to your current
221branch), upgrade node modules and rebuild client application:
222
223```bash
224# systemctl stop peertube
225$ npm run upgrade-peertube
226# systemctl start peertube
227```
diff --git a/support/systemd/peertube.service b/support/systemd/peertube.service
index 1e3378f77..b9d01f235 100644
--- a/support/systemd/peertube.service
+++ b/support/systemd/peertube.service
@@ -1,5 +1,6 @@
1[Unit] 1[Unit]
2Description=PeerTube daemon 2Description=PeerTube daemon
3After=network.target
3 4
4[Service] 5[Service]
5Type=simple 6Type=simple