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 Edit the main configuration:
35 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/application.yml.example config/application.yml</span>
36 </code></pre></notextile>
38 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.
40 For a development site, use your own domain instead of arvadosapi.com.
42 Make sure a clone of the arvados repository exists in @git_repositories_dir@:
45 <pre><code>~/arvados/services/api$ <span class="userinput">sudo mkdir -p /var/cache/git</span>
46 ~/arvados/services/api$ <span class="userinput">sudo git clone --bare ../../.git /var/cache/git/arvados.git</span>
47 </code></pre></notextile>
49 Generate a new secret token for signing cookies:
52 <pre><code>~/arvados/services/api$ <span class="userinput">rake secret
53 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
54 </code></pre></notextile>
56 Put it in @config/application.yml@ in the production or common section:
59 <pre><code><span class="userinput"> secret_token: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</span>
63 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@.
65 Configure the database:
68 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/database.yml.sample config/database.yml</span>
69 </code></pre></notextile>
71 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:
74 <pre><code>~/arvados/services/api$ <span class="userinput">RAILS_ENV=development bundle exec rake db:setup</span>
75 </code></pre></notextile>
80 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/initializers/omniauth.rb.example config/initializers/omniauth.rb
81 </code></pre></notextile>
83 Edit @config/initializers/omniauth.rb@. Set @APP_SECRET@ to the value of @app_secret@ from "installing the single sign on server":install-sso.html .
85 You can now run the development server:
88 <pre><code>~/arvados/services/api$ <span class="userinput">rails server
89 </code></pre></notextile>
91 h3. Apache/Passenger (optional)
93 You can use "Passenger":https://www.phusionpassenger.com/ for deployment. Point it to the services/api directory in the source tree.
95 To enable streaming so users can monitor crunch jobs in real time, add to your Passenger configuration in Apache:
98 <pre><code><span class="userinput">PassengerBufferResponse off</span>
102 h2. Add an admin user
104 Point browser to the API endpoint. Log in with a google account.
106 In the rails console:
109 <pre><code>~/arvados/services/api$ <span class="userinput">rails console</span>
110 irb(main):001:0> <span class="userinput">Thread.current[:user] = User.find(1)</span>
111 irb(main):002:0> <span class="userinput">Thread.current[:user].is_admin = true</span>
112 irb(main):003:0> <span class="userinput">User.find(1).update_attributes is_admin: true, is_active: true</span>
113 irb(main):004:0> <span class="userinput">User.find(1).is_admin</span>
115 </code></pre></notextile>
117 h2. Create an API token
122 <pre><code>~/arvados/services/api$ <span class="userinput">rails console</span>
123 irb(main):001:0> <span class="userinput">a = ApiClient.new(owner_uuid:'0')</span>
124 irb(main):002:0> <span class="userinput">a.save!</span>
125 irb(main):003:0> <span class="userinput">x = ApiClientAuthorization.new(api_client_id:a.id, user_id:1)</span>
126 irb(main):004:0> <span class="userinput">x.save</span>
127 irb(main):005:0> <span class="userinput">x.api_token</span>
128 </code></pre></notextile>