-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
167 lines (125 loc) · 6.04 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
2050 COSTS WIKI
This is the code used to collect cost data as part of the DECC 2050 Pathways Project.
It is a wiki, with some extra models to collect and plot costs.
It is a bit of a bodge.
It is a ruby on rails app.
RUNNING LOCALY
Depends on:
Ruby 1.9.2
sqlite3 # for development
Mysql # for production, other databases with tinkering
Setup (from inside the app directory):
gem install bundler
gem install foreman
bundle
bundle exec rake db:migrate RAILS_ENV=development
bundle exec rake db:migrate RAILS_ENV=production
May need to adjust the config.action_mailer settings in config/environments/production.rb
If updating from earlier version, may need to run:
./script/rails generate delayed_job:upgrade
bundle exec rake db:migrate RAILS_ENV=development
bundle exec rake db:migrate RAILS_ENV=production
Optionally, to enable notification of changed pages, add this to a crontab:
'ChangeNotifications.send_all_change_notifications'
To make the registration captcha work, need to register with http://www.google.com/recaptcha then set two environment variables:
export RECAPTCHA_PUBLIC_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
export RECAPTCHA_PRIVATE_KEY = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
These environment variables could also be placed in the config/development.env or config/production.env files if needed.
To start (from inside the app directory):
foreman start --env config/development.env # or --env config/production.env
Then go to http://0.0.0.0:5100
Then register a new email address.
Then you will need to manually make this first account an administrator:
./script/rails console development # or ./script/rails console production
u = User.find_by_email 'the email address you used for registration'
u.activated = true
u.administrator = true
u.save
exit
You can then use that account to log onto the wiki and create your first page.
Because the account is an administrator, you can use it to activate later accounts that are registered.
To make other users administrators, follow the steps above for the first account.
RUNNING ON HEROKU
Need an account with http://www.heroku.com
NB: Get is running locally using the instructions above first.
Depends on:
Ruby 1.9.2
Git
Setup:
gem install heroku
# if you don't already have a ssh key, then:
# ssh-keygen -t rsa
# if you don't already have a heroku account, register, then:
# heroku keys:add
# Now setup the heroku stack
heroku create --stack cedar
heroku addons:add sendgrid:free
heroku addons:add websolr
heroku addons:add cron:daily
heroku addons:add custom_domains
heroku addons:add pgbackups:basic
# Now transfer the code up to heroku
git push heroku master
# Now setup the database
heroku run rake db:migrate
# Now start the app running
heroku ps:scale web=1 worker=1
Other useful commands:
heroku run rake sunspot:reindex # if you upload a new database, this will get the search in sync
heroku domains:add 2050-wiki.greenonblack.com # to setup with a new url
heroku info
pgbackups:capture # Make a backup of the database
RUNNING ON EC2
#!/bin/bash
# This is a bootstrap file to get everything setup on an Ubuntu system
# Such as an appropriate amazon ec2 instance
# I strongly recommend that you DO NOT RUN THIS FILE on a system that
# you are already using for other purposes. Just use it as inspiration
# for what you may need to install.
# For instance, you may have created an Amazon ec2 instance like so:
# ec2-run-instances ami-fb9ca98f --instance-type t1.micro --region eu-west-1 --key deccaws
echo "Update and upgrade the system debs"
sudo apt-get -y update
sudo apt-get -y upgrade
echo "Get rvm setup so that we can install a modern version of ruby"
sudo apt-get -y install git-core build-essential zlib1g-dev libreadline5-dev libssl-dev libxml2-dev libxslt-dev
( curl http://rvm.beginrescueend.com/releases/rvm-install-latest ) | bash # This is obviously VERY INSECURE
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' > ~/.profile
source ~/.rvm/scripts/rvm
echo "Now install and select ruby 1.9.2"
rvm install 1.9.2
rvm --default use 1.9.2
echo "Get an appropriate database backend going, for simplicity we use sqlite"
sudo apt-get -y install sqlite3 libsqlite3-dev
# We could have used mysql, but would need to update config/database.yml
# sudo apt-get -y install mysql-client mysql-server
# #############################################################
# STOP HERE. This should be sufficient for light use. #
# Install apache, etc for production use only #
# #############################################################
echo "Install apache"
sudo apt-get -y install apache2 apache2-dev libcurl4-openssl-dev
echo "Install mod_rails/passenger"
gem install --no-rdoc --no-ri passenger
passenger-install-apache2-module -a
echo "Setup the passenger module"
# FIXME: Make this discover the location of the passenger gem automatically
# FIXME: Make this discover the location of the ruby bin automatically
sudo echo "LoadModule passenger_module /home/ubuntu/.rvm/gems/ruby-1.9.2-p136/gems/passenger-3.0.2/ext/apache2/mod_passenger.so" > /etc/apache2/mods-available/passenger.load
sudo echo "PassengerRoot /home/ubuntu/.rvm/gems/ruby-1.9.2-p136/gems/passenger-3.0.2" > /etc/apache2/mods-available/passenger.conf
sudo echo "PassengerRuby /home/ubuntu/.rvm/wrappers/ruby-1.9.2-p136/ruby" >> /etc/apache2/mods-available/passenger.conf
sudo a2enmod passenger
echo "Setup the site"
DIRECTORY="$( cd "$( dirname "$0" )" && pwd )/public"
URL="`curl http://169.254.169.254/latest/meta-data/public-hostname`"
SITE_CONF="/etc/apache2/sites-available/twenty-fifty"
sudo echo "<VirtualHost *:80>" > $SITE_CONF
sudo echo " ServerName $URL" >> $SITE_CONF
sudo echo " DocumentRoot $DIRECTORY" >> $SITE_CONF
sudo echo " <Directory $DIRECTORY>" >> $SITE_CONF
sudo echo " AllowOverride all" >> $SITE_CONF
sudo echo " Options -MultiViews" >> $SITE_CONF
sudo echo " </Directory>" >> $SITE_CONF
sudo echo "</VirtualHost>" >> $SITE_CONF
sudo a2ensite twenty-fifty
sudo apache2ctl graceful