Save logs to a temp file and commit to Keep via 'arv keep put'. Refs #2221.
[arvados.git] / doc / install / install-api-server.html.md.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install the API server
5 navorder: 1
6 ...
7
8 # API server setup
9
10 ## Prerequisites:
11
12 1. A GNU/Linux (virtual) machine
13 2. A domain name for your api server
14 3. Ruby >= 2.0.0
15 4. Bundler: `gem install bundler`
16 5. Curl libraries: `sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev`
17
18 ## Download the source tree
19
20     git clone https://github.com/curoverse/arvados.git
21     cd arvados
22
23 See also: [Downloading the source code](https://arvados.org/projects/arvados/wiki/Download) on the Arvados wiki.
24
25 ## Install gem dependencies
26
27     cd services/api && bundle install
28
29 ## Configure the API server
30
31 Configure the database:
32
33     cp -i config/database.yml.sample config/database.yml
34
35 Edit `config/database.yml` to your liking and make sure the database
36 and db user exist. Then set up the database:
37  
38     RAILS_ENV=production bundle exec rake db:setup
39
40 Then set up omniauth:
41
42     cp -i config/initializers/omniauth.rb.example config/initializers/omniauth.rb
43
44 Edit `config/initializers/omniauth.rb`. Choose an *APP_SECRET* and
45 *APP_ID*. Also set *CUSTOM_PROVIDER_URL*.
46
47 Make sure your Omniauth provider knows about your *APP_ID* and *APP_SECRET*
48 combination.
49
50 Edit the main configuration.
51
52     cp -i config/application.yml.example config/application.yml
53
54 First, choose a unique 5-character alphanumeric string to use as your
55 `uuid_prefix`. An example is given that generates a 5-character string
56 based on a hash of your hostname. The `uuid_prefix` is a unique
57 identifier for your API server. It also serves as the first part of
58 the hostname for your API server:
59
60     {{ site.arvados_api_host }}
61
62 For a development site, use your own domain instead of arvadosapi.com.
63
64 You also need to install a secret_token for signing cookies. Generate
65 a new secret:
66
67     rake secret
68
69 Put it in `config/application.yml` in the production or common section:
70
71     secret_token: your-new-secret-here
72
73 You will also want to change `compute_node_nameservers` to suit your
74 environment.
75
76 Consult `application.default.yml` for a full list of configuration
77 options. Always put your local configuration in `application.yml`
78 instead of editing `application.default.yml`.
79
80 ## Apache/Passenger
81
82 Set up Apache and Passenger. Point them to the services/api directory in the source tree.
83
84 To enable streaming so users can monitor crunch jobs in real time, add
85 to your Apache configuration:
86
87     PassengerBufferResponse off
88
89 ## Add an admin user
90
91 Point browser to the API endpoint. Log in with a google account.
92
93 In the rails console:
94
95     Thread.current[:user] = User.find(1)
96     Thread.current[:user].is_admin = true
97     User.find(1).update_attributes is_admin: true, is_active: true
98     User.find(1).is_admin
99
100 This should be
101
102      => true
103
104 ## Create a token
105
106 In rails console
107
108      a = ApiClient.new(owner_uuid:'0'); a.save!
109      x = ApiClientAuthorization.new(api_client_id:a.id, user_id:1); x.save; x.api_token
110