Project

General

Profile

Installing the Tapestry application » History » Version 43

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