Project

General

Profile

Installing the Tapestry application » History » Version 39

Ward Vandewege, 01/04/2014 06:16 PM
update configuration instructions (cf. #1631)

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