-
Notifications
You must be signed in to change notification settings - Fork 7
Adventures in local web app instance installation
I recently (10/1/2019) installed eol_website on a GNU/Linux laptop (distro = PureOS which is similar to Ubuntu). Here is a cleaned up version of what I did. I may have made mistakes in the cleanup process, but maybe this information will be useful.
UPDATE 3/20/2020: Ruby version is now 2.6.5; added further webapp setup instructions
sudo apt-get install libmariadb-dev
sudo apt-get install mariadb-server
cp -p config/secrets.sample.yml config/secrets.tml
<add json_web_token_secret: ... to the secrets file>
<start mariadb = mysql>
sudo mysql_secure_installation
<set the root password if you've forgotten it>
sudo mysql -u root -p
create user 'eol'@'localhost' identified by 'eol';
create database eol_development;
grant all privileges on eol_development.* to 'eol'@'localhost';
flush privileges;
As of 3/20/2020, the EOL production server is running neo4j 3.5.7. I am gambling here that 3.5.11 is compatible, but to be careful us 3.5.7 (or whatever you know to be running at SI).
sudo apt-get install openjdk-8-jdk
<download Neo4j Community Edition 3.5.11 from neo4j.com>
tar xzf ~/Downloads/neo4j-community-3.5.11-unix.tar.gz
cd /usr/local/src; tar xzf ~/Downloads/neo4j-community-3.5.11-unix.tar.gz
/usr/local/src/neo4j-community-3.5.11/bin/neo4j start
I run neo4j in user mode, as it is not necessary to run it as root and running daemons in user mode is good security hygiene. I restart it manually after each reboot.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.1-amd64.deb
sudo dpkg -i elasticsearch-7.2.1-amd64.deb
sudo systemctl start elasticsearch
Like it says.
Then cd
to the main directory of that clone.
sudo apt-get install rbenv
rbenv init
Add the following to your .bashrc: eval "$(rbenv init -)"
.
Restart bash to activate this command.
The following is necessary only if rbenv install
says it has never heard of the ruby version you asked it to install. (ruby-build
has a hardwired list of available ruby versions and sometimes it gets out of date.)
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
Now get the right version.
rbenv install 2.6.5
rbenv rehash
Get its 'gems':
bin/bundle
(I had considerable trouble getting the currect version of bundle
but it's my belief that that issue has been resolved.)
Copy config/secrets.sample.yml to config/secrets.yml and edit it as follows:
- Under
db:
, setusername: eol
andpassword: eol
- Under
repository:
, seturl:
to eitherhttps://beta-repo.eol.org
orhttps://content.eol.org
(I'm not sure which would be better for general development... beta is missing 1/3 of the resources, and is usually behind production, but sometimes it has experimental resource versions that need to be tested) - Set neo4j username and password if you changed them (see mariadb setup - suggestion there is user
eol
and passwordeol
) - Under
development:
addjson_web_token_secret: xxx
wherexxx
is a random hex string (if your local instance is not on the Internet then doesn't much matter what you put there)
bin/rake db:environment:set RAILS_ENV=development
bin/rake db:schema:load RAILS_ENV=development
N.b. db:schema:load
is only for a fresh database. Use db:migrate
under ordinary circumstances.
bin/rails s
<get api token if you want to use web services>
For more durable server access do something like
nohup bin/rails s >rails.nohup &
bin/rails r "TraitBank::Admin.setup"
bin/rails r "ImportRun.delete_all"
bin/rails r 'user = User.create!({email: "[email protected]", \
username: "admin", password: "not-in-wiki", role: :admin, \
age_confirm: 1, tou_confirm: 1}); user.activate'
(actually that user setup command doesn't work; no way to log in... TBD)
bin/rake sync
At this point all the local resource ids (id
column of the resources
table) are essentially random. We would like for them to agree with the EOL resource repository that we synced with (specified in secrets.yml
) so that we can load resources. To do this we need to get ahold of the correct ids, and alter the keys in the resources
table in the database.
First, to ensure we don't have resource records that compete (even if transiently) for unique ids with the records that deserve them, modify all the ids so they don't conflict. At the mysql prompt, do this:
update resources set id = id + 10000;
Now get the correct ids from the publishing site you want to be consistent with: (note, not a harvesting/repository site)
wget "http://eol.org/resources.json?per_page=1000"
Finally, renumber the resource records using SQL UPDATE
. The following script will do this (it deserves a better home)
wget https://github.com/jar398/testbed/blob/master/clobber_resource_ids.rb
bin/rails r clobber_resource_ids.rb
At the very least, you'll need the dynamic hierarchy. You have to get the resource id for each resource you want to 'publish' (TBD - not sure the best way to do this - search on content.eol.org/resources or something?). E.g. the following should load the dynamic hierarchy:
bin/rake publish ID=724
Hmm, I can't get this to work...
This might be useful:
bin/rails r TraitBank::Denormalizer.set_canonicals
If you want to work with some representative clade instead of the entire DH:
bin/rake clade:read CLADE_FILE=7662_data.tgz
except this doesn't seem to work.
Maybe in future for benefit of neo4j: increase OS limit on number of open files