15924: Update github links to arvados org.
[arvados.git] / doc / install / install-ws.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install the websocket server
5 ...
6 {% comment %}
7 Copyright (C) The Arvados Authors. All rights reserved.
8
9 SPDX-License-Identifier: CC-BY-SA-3.0
10 {% endcomment %}
11
12 The arvados-ws server provides event notifications to websocket clients. It can be installed anywhere with access to Postgres database and the Arvados API server, typically behind a web proxy that provides SSL support. See the "godoc page":http://godoc.org/github.com/arvados/arvados/services/ws for additional information.
13
14 By convention, we use the following hostname for the websocket service.
15
16 <notextile>
17 <pre><code>ws.<span class="userinput">uuid_prefix.your.domain</span></code></pre>
18 </notextile>
19
20 The above hostname should resolve from anywhere on the internet.
21
22 h2. Install arvados-ws
23
24 Typically arvados-ws runs on the same host as the API server.
25
26 On Debian-based systems:
27
28 <notextile>
29 <pre><code>~$ <span class="userinput">sudo apt-get install arvados-ws</span>
30 </code></pre>
31 </notextile>
32
33 On Red Hat-based systems:
34
35 <notextile>
36 <pre><code>~$ <span class="userinput">sudo yum install arvados-ws</span>
37 </code></pre>
38 </notextile>
39
40 Verify that @arvados-ws@ is functional:
41
42 <notextile>
43 <pre><code>~$ <span class="userinput">arvados-ws -h</span>
44 Usage of arvados-ws:
45   -config path
46         path to config file (default "/etc/arvados/config.yml")
47   -dump-config
48         show current configuration and exit
49 </code></pre>
50 </notextile>
51
52 h3. Update cluster config
53
54 Edit the cluster config at @/etc/arvados/config.yml@ and set @Services.Websocket.ExternalURL@ and @Services.Websocket.InternalURLs@.  Replace @zzzzz@ with your cluster id.
55
56 <notextile>
57 <pre><code>Clusters:
58   zzzzz:
59     Services:
60       <span class="userinput">Websocket:
61         ExternalURL: wss://ws.uuid_prefix.your.domain/websocket
62         InternalURLs:
63           "http://localhost:9003": {}
64 </span></code></pre>
65 </notextile>
66
67 h3. Start the service (option 1: systemd)
68
69 If your system does not use systemd, skip this section and follow the "runit instructions":#runit instead.
70
71 If your system uses systemd, the arvados-ws service should already be set up. Start it and check its status:
72
73 <notextile>
74 <pre><code>~$ <span class="userinput">sudo systemctl restart arvados-ws</span>
75 ~$ <span class="userinput">sudo systemctl status arvados-ws</span>
76 &#x25cf; arvados-ws.service - Arvados websocket server
77    Loaded: loaded (/lib/systemd/system/arvados-ws.service; enabled)
78    Active: active (running) since Tue 2016-12-06 11:20:48 EST; 10s ago
79      Docs: https://doc.arvados.org/
80  Main PID: 9421 (arvados-ws)
81    CGroup: /system.slice/arvados-ws.service
82            └─9421 /usr/bin/arvados-ws
83
84 Dec 06 11:20:48 zzzzz arvados-ws[9421]: {"level":"info","msg":"started","time":"2016-12-06T11:20:48.207617188-05:00"}
85 Dec 06 11:20:48 zzzzz arvados-ws[9421]: {"Listen":":9003","level":"info","msg":"listening","time":"2016-12-06T11:20:48.244956506-05:00"}
86 Dec 06 11:20:48 zzzzz systemd[1]: Started Arvados websocket server.
87 </code></pre>
88 </notextile>
89
90 If it is not running, use @journalctl@ to check logs for errors:
91
92 <notextile>
93 <pre><code>~$ <span class="userinput">sudo journalctl -n10 -u arvados-ws</span>
94 ...
95 Dec 06 11:12:48 zzzzz systemd[1]: Starting Arvados websocket server...
96 Dec 06 11:12:48 zzzzz arvados-ws[8918]: {"level":"info","msg":"started","time":"2016-12-06T11:12:48.030496636-05:00"}
97 Dec 06 11:12:48 zzzzz arvados-ws[8918]: {"error":"pq: password authentication failed for user \"arvados\"","level":"fatal","msg":"db.Ping failed","time":"2016-12-06T11:12:48.058206400-05:00"}
98 </code></pre>
99 </notextile>
100
101 Skip ahead to "confirm the service is working":#confirm.
102
103 h3(#runit). Start the service (option 2: runit)
104
105 Install runit to supervise the arvados-ws daemon.  {% include 'install_runit' %}
106
107 Create a supervised service.
108
109 <notextile>
110 <pre><code>~$ <span class="userinput">sudo mkdir /etc/service/arvados-ws</span>
111 ~$ <span class="userinput">cd /etc/service/arvados-ws</span>
112 ~$ <span class="userinput">sudo mkdir log log/main</span>
113 ~$ <span class="userinput">printf '#!/bin/sh\nexec arvados-ws 2>&1\n' | sudo tee run</span>
114 ~$ <span class="userinput">printf '#!/bin/sh\nexec svlogd main\n' | sudo tee log/run</span>
115 ~$ <span class="userinput">sudo chmod +x run log/run</span>
116 ~$ <span class="userinput">sudo sv exit .</span>
117 ~$ <span class="userinput">cd -</span>
118 </code></pre>
119 </notextile>
120
121 Use @sv stat@ and check the log file to verify the service is running.
122
123 <notextile>
124 <pre><code>~$ <span class="userinput">sudo sv stat /etc/service/arvados-ws</span>
125 run: /etc/service/arvados-ws: (pid 12520) 2s; run: log: (pid 12519) 2s
126 ~$ <span class="userinput">tail /etc/service/arvados-ws/log/main/current</span>
127 {"level":"info","msg":"started","time":"2016-12-06T11:56:20.669171449-05:00"}
128 {"Listen":":9003","level":"info","msg":"listening","time":"2016-12-06T11:56:20.708847627-05:00"}
129 </code></pre>
130 </notextile>
131
132 h3(#confirm). Confirm the service is working
133
134 Confirm the service is listening on its assigned port and responding to requests.
135
136 <notextile>
137 <pre><code>~$ <span class="userinput">curl http://0.0.0.0:<b>9003</b>/status.json</span>
138 {"Clients":1}
139 </code></pre>
140 </notextile>
141
142 h3. Set up a reverse proxy with SSL support
143
144 The arvados-ws service will be accessible from anywhere on the internet, so we recommend using SSL for transport encryption.
145
146 This is best achieved by putting a reverse proxy with SSL support in front of arvados-ws, running on port 443 and passing requests to arvados-ws on port 9003 (or whatever port you chose in your configuration file).
147
148 For example, using Nginx:
149
150 <notextile><pre>
151 upstream arvados-ws {
152   server                127.0.0.1:<span class="userinput">9003</span>;
153 }
154
155 server {
156   listen                <span class="userinput">[your public IP address]</span>:443 ssl;
157   server_name           ws.<span class="userinput">uuid_prefix.your.domain</span>;
158
159   proxy_connect_timeout 90s;
160   proxy_read_timeout    300s;
161
162   ssl                   on;
163   ssl_certificate       <span class="userinput"/>YOUR/PATH/TO/cert.pem</span>;
164   ssl_certificate_key   <span class="userinput"/>YOUR/PATH/TO/cert.key</span>;
165
166   location / {
167     proxy_pass          http://arvados-ws;
168     proxy_set_header    Upgrade         $http_upgrade;
169     proxy_set_header    Connection      "upgrade";
170     proxy_set_header    Host            $host;
171     proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
172   }
173 }
174 </pre></notextile>
175
176 {% include 'notebox_begin' %}
177 If you are upgrading a cluster where Nginx is configured to proxy @ws@ requests to puma, change the @server_name@ value in the old configuration block so it doesn't conflict. When the new configuration is working, delete the old Nginx configuration sections (i.e., the "upstream websockets" block, and the "server" block that references @http://websockets@), and disable/remove the runit or systemd files for the puma server.
178 {% include 'notebox_end' %}
179
180 h3. Update API server configuration
181
182 Restart Nginx to reload the API server configuration.
183
184 <notextile>
185 <pre><code>$ sudo nginx -s reload</span>
186 </code></pre>
187 </notextile>
188
189 h3. Verify DNS and proxy setup
190
191 Use a host elsewhere on the Internet to confirm that your DNS, proxy, and SSL are configured correctly.  For @Authorization: Bearer xxxx@ replace @xxxx@ with the value from @ManagementToken@ in @config.yml@.
192
193 <notextile>
194 <pre><code>$ <span class="userinput">curl -H "Authorization: Bearer xxxx" https://ws.<b>uuid_prefix.your.domain</b>/_health/ping</span>
195 {"health":"OK"}
196 </code></pre>
197 </notextile>