Project

General

Profile

Installing the Tapestry application » History » Version 47

Tom Clegg, 07/23/2015 03:06 AM

1 20 Tom Clegg
h1. Installing the Tapestry application
2 1 Tom Clegg
3 33 Tom Clegg
* ...or skip down to the [[Installing the Tapestry application#Updating|section about Updating]]
4
5 27 Ward Vandewege
The recommended ruby stack for Tapestry is Ruby Enterprise Edition (1.8.7), installed via rvm.
6
7 29 Tom Clegg
Install rvm and REE:
8 1 Tom Clegg
9 29 Tom Clegg
<pre>
10
sudo -i
11 46 Tom Clegg
# apt-get install curl
12
# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
13
# \curl -L https://get.rvm.io | sudo bash -s stable
14 29 Tom Clegg
# exit
15
sudo -i
16
# rvm install ree
17
# exit
18
</pre>
19 1 Tom Clegg
20 29 Tom Clegg
Start a new login shell.  Make sure RVM is working and @ruby -v@ identifies itself as REE 1.8.7.
21 1 Tom Clegg
22 29 Tom Clegg
 rvm use ree
23
ruby -v
24 1 Tom Clegg
25 29 Tom Clegg
&rarr; *@ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2012.02@*
26
27 1 Tom Clegg
Install rails.
28
29 29 Tom Clegg
<pre>
30
sudo -i
31
# rvm use ree
32
# gem install passenger
33
# passenger-install-apache2-module
34
</pre>
35 1 Tom Clegg
36 47 Tom Clegg
Add three lines (provided by passenger-install-apache2-module) and two more lines (see below) to @/etc/apache2/conf-enabled/passenger.conf@.
37 1 Tom Clegg
38 23 Tom Clegg
<pre>
39 29 Tom Clegg
LoadModule passenger_module /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
40
PassengerRoot /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.17
41
PassengerRuby /usr/local/rvm/wrappers/ree-1.8.7-2012.02/ruby
42
43
PassengerUser YOUR_USERNAME_HERE
44 22 Tom Clegg
RackEnv "development"
45
</pre>
46
47 42 Ward Vandewege
Install some prerequisites for gems and the DRB server.
48 28 Tom Clegg
49 45 Tom Clegg
 sudo apt-get install libxslt-dev libxml2-dev lsof daemon libmysqlclient-dev
50 28 Tom Clegg
51 1 Tom Clegg
Get a copy of the source tree -- e.g., in /var/www/tapestry
52 28 Tom Clegg
53
<pre>
54
cd /var/www
55 1 Tom Clegg
sudo chmod a+w,+t .
56 41 Ward Vandewege
git clone https://github.com/curoverse/tapestry.git
57 28 Tom Clegg
sudo chmod go-w,-t .
58
cd tapestry && git submodule init && git submodule update
59 12 Ward Vandewege
</pre>
60
61 3 Tom Clegg
Then execute:
62 2 Tom Clegg
63 43 Phil Hodgson
 bundle install --deployment
64 1 Tom Clegg
65 47 Tom Clegg
Point a virtualhost to the @public@ dir in your git repo. For example, in @/etc/apache2/sites-available/tapestry.conf@:
66 1 Tom Clegg
67 21 Tom Clegg
<pre>
68 28 Tom Clegg
<VirtualHost *:80>
69
   ServerName tapestry.example.org
70 1 Tom Clegg
   DocumentRoot /var/www/tapestry/public
71
   <Directory /var/www/tapestry/public>
72
         AllowOverride all
73 26 Tom Clegg
         Options -MultiViews
74
   </Directory>
75
   Alias /warehouse /warehouse
76
   <Directory /warehouse>
77 32 Ward Vandewege
         # This is important; downloads from /warehouse take a long time
78
         # and we do not want to tie up passenger processes with those.
79
         PassengerEnabled off
80 26 Tom Clegg
         Options None
81
         AllowOverride None
82
         Order allow,deny
83 1 Tom Clegg
         allow from all
84
   </Directory>
85
</VirtualHost>
86 47 Tom Clegg
</pre>
87
88
Enable the vhost.
89
90
<pre>
91
sudo a2ensite tapestry
92 14 Tom Clegg
</pre>
93 1 Tom Clegg
94 14 Tom Clegg
Copy @config/database.example@ to @config/database.yml@ and edit to suit. Make sure to select mysql as the database server.  Generate a password using @pwgen 12 1@ or @head -c12345 /dev/urandom|md5sum|head -c12;echo@.  For example:
95
96
 development:
97 15 Tom Clegg
  adapter: mysql
98
  server: localhost
99 14 Tom Clegg
  database: mypg
100
  username: mypg
101
  password: c16fbe415d29
102 18 Madeleine Ball
  timeout: 5000
103 16 Tom Clegg
104 39 Ward Vandewege
Copy @config/environments/development.rb.example@ to @config/environments/development.rb@ and edit it. You will probably want to update the ActionMailer::Base.smtp_settings section.
105 14 Tom Clegg
106 39 Ward Vandewege
Create a new file @config/config.yml and add a 'development' section to override a few of the defaults configured in @config/config.defaults.yml. You should override these values to get started:
107 1 Tom Clegg
108 40 Ward Vandewege
<pre>
109 39 Ward Vandewege
  root_url
110
  root_url_scheme
111 40 Ward Vandewege
</pre>
112 39 Ward Vandewege
113
For a test/development setup, your @config/config.yml file could look like this:
114
115
<pre>
116
development:
117
  root_url: 'hostname.of.your.machine'
118
  root_url_scheme: 'http://'
119
</pre>
120
121
For a production setup, you are going to want to override most other variables defined in @config/config.defaults.yml.
122
123 30 Tom Clegg
Generate a secret token with something like
124
125
* @ruby -e 'puts rand(2**256).to_s(36)'@
126
* @head -c1234567 /dev/urandom | sha256sum@
127
* @pwgen 64 1@
128
129
Put the secret token in @config/initializers/secret_token.rb@ like this
130
131 31 Tom Clegg
 Tapestry::Application.configure do
132 30 Tom Clegg
 config.secret_token = "40ih46sqyihsiupgwce5u2oirflnor3atgmvzaqeqng42dwa0o"
133 31 Tom Clegg
end
134 30 Tom Clegg
135 1 Tom Clegg
Set up the database:
136 19 Madeleine Ball
137 18 Madeleine Ball
 rake db:setup
138 1 Tom Clegg
rake db:schema:load
139 19 Madeleine Ball
140 33 Tom Clegg
Seed the database with a default set of enrollment steps:
141
142
 rake db:seed_enrollment_steps
143
144 25 Tom Clegg
Set up data directory (replace USERNAME with the user who owns the GIT directory this code is in, and ROOT_URL matching the one above):
145 1 Tom Clegg
146
 sudo mkdir -p /data/ROOT_URL
147 30 Tom Clegg
sudo chown -R USERNAME:USERNAME /data/ROOT_URL
148 25 Tom Clegg
149 35 Ward Vandewege
Set up cron jobs -- 
150
151
1. populate NextHex table regularly (daily is probably ok):
152
153 44 Phil Hodgson
 SHELL=/bin/bash
154
PATH=/usr/local/bin:/usr/bin:/bin
155
38 0 * * *  www-data  (source /usr/local/rvm/environments/ree-1.8.7-2012.02@global; cd /var/www/tapestry/script; ./populate_next_hex.rb production) 2>/dev/null
156
157 35 Ward Vandewege
158
2. Optionally: @/etc/cron.d/tapestry-get-blog-feed@
159 28 Tom Clegg
160 26 Tom Clegg
 PATH=/usr/local/bin:/usr/bin:/bin
161
0 * * * * www-data cd /var/www/tapestry/current/script && ./get-blog-feed.rb development http://blog.personalgenomes.org/feed/
162
163
To enable large uploads with warehouse storage:
164
165
* @sudo apt-get install runit fuse-utils@
166
* @sudo mkdir -p /etc/service/whmount/log/main@
167 37 Tom Clegg
* @sudo usermod -a -G fuse www-data@
168 26 Tom Clegg
* Set up supervised whmount service:
169
170
<pre>
171
sudo tee /etc/service/whmount/run <<EOF >/dev/null
172
#!/bin/sh
173
modprobe fuse
174
mkdir -p /warehouse
175
chown www-data:www-data /warehouse
176 36 Tom Clegg
sudo -u www-data fusermount -u /warehouse
177
exec sudo -u www-data whmount --no-detach --threaded / /warehouse 2>&1
178
EOF
179 26 Tom Clegg
sudo chmod +t /etc/service/whmount
180
sudo chmod +x /etc/service/whmount/run
181 1 Tom Clegg
182
sudo tee /etc/service/whmount/log/run <<EOF >/dev/null
183 36 Tom Clegg
#!/bin/sh
184 1 Tom Clegg
exec svlogd -tt main
185
EOF
186
sudo chmod +x /etc/service/whmount/log/run
187
</pre>
188
189 39 Ward Vandewege
* Make sure config/config.yml matches your Apache and filesystem mount points:
190 1 Tom Clegg
191
<pre>
192 39 Ward Vandewege
  warehouse_web_root: "/warehouse" # Apache alias pointing to whmount target
193
  warehouse_fs_root: "/warehouse" # whmount target
194 1 Tom Clegg
</pre>
195 33 Tom Clegg
196
h1. Updating
197
198
Pull the latest source tree.
199
200
 git pull
201
202
Install/update gem package dependencies.
203
204 43 Phil Hodgson
 bundle install --deployment
205 33 Tom Clegg
206
Bring your database up to the latest release.
207
208
 rake db:migrate
209
210
Tell passenger to reload everything.
211
212
 mkdir -p tmp
213
touch tmp/restart.txt