3 navsection: installguide
4 title: Install the API server
9 # A GNU/Linux (virtual) machine
10 # A domain name for your api server
12 h2(#dependencies). Install dependencies
15 <pre><code>~$ <span class="userinput">sudo apt-get install \
16 bison build-essential gettext libcurl3 libcurl3-gnutls \
17 libcurl4-openssl-dev libpcre3-dev libpq-dev libreadline-dev \
18 libsqlite3-dev libssl-dev libxslt1.1 postgresql sqlite3 sudo \
20 </span></code></pre></notextile>
22 h2(#ruby). Install Ruby and bundler
24 We recommend Ruby >= 2.1.
27 <pre><code><span class="userinput">mkdir -p ~/src
29 wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
30 tar xzf ruby-2.1.2.tar.gz
36 sudo gem install bundler</span>
37 </code></pre></notextile>
39 h2. Download the source tree
42 <pre><code>~$ <span class="userinput">cd $HOME</span> # (or wherever you want to install)
43 ~$ <span class="userinput">git clone https://github.com/curoverse/arvados.git</span>
44 </code></pre></notextile>
46 See also: "Downloading the source code":https://arvados.org/projects/arvados/wiki/Download on the Arvados wiki.
48 h2. Install gem dependencies
51 <pre><code>~$ <span class="userinput">cd arvados/services/api</span>
52 ~/arvados/services/api$ <span class="userinput">bundle install</span>
53 </code></pre></notextile>
55 h2. Configure the API server
57 Edit the main configuration:
60 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/application.yml.example config/application.yml</span>
61 </code></pre></notextile>
63 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.
65 For a development site, use your own domain instead of arvadosapi.com.
67 Make sure a clone of the arvados repository exists in @git_repositories_dir@:
70 <pre><code>~/arvados/services/api$ <span class="userinput">sudo mkdir -p /var/cache/git</span>
71 ~/arvados/services/api$ <span class="userinput">sudo git clone --bare ../../.git /var/cache/git/arvados.git</span>
72 </code></pre></notextile>
74 Generate a new secret token for signing cookies:
77 <pre><code>~/arvados/services/api$ <span class="userinput">rake secret</span>
78 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
79 </code></pre></notextile>
81 Put it in @config/application.yml@ in the production or common section:
84 <pre><code><span class="userinput"> secret_token: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</span>
88 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@.
90 Generate a new database password. Nobody ever needs to memorize it or type it, so we'll make a strong one:
93 <pre><code>~/arvados/services/api$ <span class="userinput">ruby -e 'puts rand(2**128).to_s(36)'</span>
94 6gqa1vu492idd7yca9tfandj3
95 </code></pre></notextile>
97 Create a new database user with permission to create its own databases.
100 <pre><code>~/arvados/services/api$ <span class="userinput">sudo -u postgres createuser --createdb --encrypted --pwprompt arvados</span>
101 [sudo] password for <b>you</b>: <span class="userinput">yourpassword</span>
102 Enter password for new role: <span class="userinput">paste-password-you-generated</span>
103 Enter it again: <span class="userinput">paste-password-again</span>
104 Shall the new role be a superuser? (y/n) <span class="userinput">n</span>
105 Shall the new role be allowed to create more new roles? (y/n) <span class="userinput">n</span>
106 </code></pre></notextile>
108 Configure API server to connect to your database by creating and updating @config/database.yml@. Replace the @xxxxxxxx@ database password placeholders with the new password you generated above.
111 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/database.yml.sample config/database.yml</span>
112 ~/arvados/services/api$ <span class="userinput">edit config/database.yml</span>
113 </code></pre></notextile>
115 Create and initialize the database.
118 <pre><code>~/arvados/services/api$ <span class="userinput">RAILS_ENV=development bundle exec rake db:setup</span>
119 </code></pre></notextile>
124 <pre><code>~/arvados/services/api$ <span class="userinput">cp -i config/initializers/omniauth.rb.example config/initializers/omniauth.rb
125 </code></pre></notextile>
127 Edit @config/initializers/omniauth.rb@. Set @APP_SECRET@ to the value of @app_secret@ from "installing the single sign on server":install-sso.html .
129 You can now run the development server:
132 <pre><code>~/arvados/services/api$ <span class="userinput">bundle exec rails server --port=3030
133 </code></pre></notextile>
135 h3. Apache/Passenger (optional)
137 You can use "Passenger":https://www.phusionpassenger.com/ for deployment. Point it to the services/api directory in the source tree.
139 To enable streaming so users can monitor crunch jobs in real time, add to your Passenger configuration in Apache:
142 <pre><code><span class="userinput">PassengerBufferResponse off</span>
146 h2(#admin-user). Add an admin user
148 Point your browser to the API server's login endpoint:
151 <pre><code><span class="userinput">https://localhost:3030/login</span>
155 Log in with your google account.
157 Use the rails console to give yourself admin privileges:
160 <pre><code>~/arvados/services/api$ <span class="userinput">bundle exec rails console</span>
161 irb(main):001:0> <span class="userinput">Thread.current[:user] = User.all.select(&:identity_url).last</span>
162 irb(main):002:0> <span class="userinput">Thread.current[:user].is_admin = true</span>
163 irb(main):003:0> <span class="userinput">Thread.current[:user].update_attributes is_admin: true, is_active: true</span>
164 irb(main):004:0> <span class="userinput">User.where(is_admin: true).collect &:email</span>
165 => ["root", "<b>your_address@example.com</b>"]
166 </code></pre></notextile>