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