3 navsection: installguide
4 title: Install the API server
9 # A GNU/Linux (virtual) machine
10 # A domain name for your api server
12 # Bundler: @gem install bundler@
13 # Curl libraries: @sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev@
15 h2. Download the source tree
18 <pre><code>~$ <span class="userinput">git clone https://github.com/curoverse/arvados.git</span>
19 </code></pre></notextile>
21 See also: "Downloading the source code:https://arvados.org/projects/arvados/wiki/Download on the Arvados wiki.
23 h2. Install gem dependencies
26 <pre><code>~$ <span class="userinput">cd arvados/services/api</span>
27 ~/arvados/services/api$ <span class="userinput">bundle install</span>
28 </code></pre></notextile>
30 h2. Configure the API server
32 Configure the database:
35 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/database.yml.sample config/database.yml</span>
36 </code></pre></notextile>
38 By default, the development database will use the sqlite3 driver, so no configuration is necessary. If you wish to use mysql or postgres, edit @config/database.yml@ to your liking and make sure the database and db user exist. Then initialize the database:
41 <pre><code>~/arvados/services/api$ <span class="userinput">RAILS_ENV=development bundle exec rake db:setup</span>
42 </code></pre></notextile>
47 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/initializers/omniauth.rb.example config/initializers/omniauth.rb
48 </code></pre></notextile>
50 Edit @config/initializers/omniauth.rb@. Set @APP_SECRET@ to the value of @app_secret@ from "installing the single sign on server":install-sso.html .
52 Next, edit the main configuration:
55 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/application.yml.example config/application.yml
56 </code></pre></notextile>
58 First, choose a unique 5-character alphanumeric string to use as your @uuid_prefix@. An example is given that generates a 5-character string based on a hash of your hostname. The `uuid_prefix` is a unique identifier for your API server. It also serves as the first part of the hostname for your API server.
60 For a development site, use your own domain instead of arvadosapi.com.
62 You also need to install a secret_token for signing cookies. Generate a new secret:
65 <pre><code>~/arvados/services/api$ <span class="userinput">rake secret
66 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
67 </code></pre></notextile>
69 Put it in @config/application.yml@ in the production or common section:
72 <pre><code><span class="userinput"> secret_token: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</span>
76 You will also want to change @compute_node_nameservers@ to suit your environment.
78 Consult @application.default.yml@ for a full list of configuration options. Always put your local configuration in @application.yml@ instead of editing @application.default.yml@.
80 You can now run the development server:
83 <pre><code>~/arvados/services/api$ <span class="userinput">rails server
84 </code></pre></notextile>
86 h3. Apache/Passenger (optional)
88 You can use "Passenger":https://www.phusionpassenger.com/ for deployment. Point it to the services/api directory in the source tree.
90 To enable streaming so users can monitor crunch jobs in real time, add to your Passenger configuration in Apache:
93 <pre><code><span class="userinput">PassengerBufferResponse off</span>
99 Point browser to the API endpoint. Log in with a google account.
101 In the rails console:
104 <pre><code>~/arvados/services/api$ <span class="userinput">rails console</span>
105 irb(main):001:0> <span class="userinput">Thread.current[:user] = User.find(1)</span>
106 irb(main):002:0> <span class="userinput">Thread.current[:user].is_admin = true</span>
107 irb(main):003:0> <span class="userinput">User.find(1).update_attributes is_admin: true, is_active: true</span>
108 irb(main):004:0> <span class="userinput">User.find(1).is_admin</span>
110 </code></pre></notextile>
112 h2. Create an API token
117 <pre><code>~/arvados/services/api$ <span class="userinput">rails console</span>
118 irb(main):001:0> <span class="userinput">a = ApiClient.new(owner_uuid:'0')</span>
119 irb(main):002:0> <span class="userinput">a.save!</span>
120 irb(main):003:0> <span class="userinput">x = ApiClientAuthorization.new(api_client_id:a.id, user_id:1)</span>
121 irb(main):004:0> <span class="userinput">x.save</span>
122 irb(main):005:0> <span class="userinput">x.api_token</span>
123 </code></pre></notextile>