Vagrant Based Hyrax Setup - RepoCamp/connect2017 GitHub Wiki
This guide walks you through the steps to set up a template generated instance of Hyrax which can be used with the other tutorials in this WIKI. We have followed the main outline of the instructions on the Hyrax github page, and we have added the steps to make using a Vagrant based virtual machine easier.
Goals:
- Start a vagrant based virtual machine
- Set up a Hyrax based rails application
- Start Solr, Fedora, and Web servers
- Be able to log into a local Hyrax instance and submit a work
Prerequisites
- Recent version of VirtualBox Installed
- Recent version of Vagrant Installed
- A Vagrantfile which loads a VM preloaded with the Hyrax perquisites
Steps
-
Start your VM using
vagrant up
and connect withvagrant ssh
. -
Navigate to your working directory -
/vagrant
will give you a VM mounted instance of the directory from which you started vagrantcd /vagrant
-
Generate a Hyrax application using the basic application template
rails _5.1.2_ new hyrax-demo -m https://raw.githubusercontent.com/samvera/hyrax/v2.0.0.rc2/template.rb
NOTE: using the template file above to set up your application is equivalent to running the following individual commands
- Run
rails _5.1.2_ new hyrax-demo
cd hyrax-demo
- Add
gem 'hyrax', '~> 2.0.0.rc2'
to your Gemfile bundle install
rails g hyrax:install -f
rails db:migrate
- Run
-
Change directory to the root of the newly generated application
cd hyrax-demo
-
For the tutorials, set background jobs to run inline by editing
config/application.rb
around line 11# after the line # class Application < Rails::Application config.active_job.queue_adapter = :inline
-
Point your solr config at the local (already downloaded) solr instance in
/var/tmp
by adding these lines to the top ofhyrax-demo/.solr_wrapper
:version: 6.6.2 download_dir: /var/tmp
-
Point your fedora config at the local (already downloaded) fedora instance in
/var/tmp
by adding these lines to the end ofhyrax-demo/.fcrepo_wrapper
:version: 4.7.4 download_dir: /var/tmp
-
Start Solr, Fedora, and Web servers in a new terminal window. You'll want to leave these running in a separate window while you use your first terminal session for command line exercises in the tutorials.
# after you open a new terminal window vagrant ssh
then, in the new terminal session after you ssh
cd /vagrant/hyrax-demo rails hydra:server
NOTE: alternatively you can start services individually and send them to the background:
cd /vagrant/hyrax-demo solr_wrapper & fcrepo_wrapper & rails s -b 0.0.0.0 &
Leave this session running for the rest of the tutorial. Hold down Ctrl-C to stop the servers, and type
exit
when you’re done with the terminal window. You can now use your primary terminal window for the remaining exercises. -
Generate the default admin set:
rails hyrax:default_admin_set:create
-
Create an ETD work type to be used in future tutorials. To generate a new work type, we follow the instructions on the Hyrax github page. In this case, our work type will be Etd (an acronym that stands for "Electronic Theses and Dissertations).
rails generate hyrax:work ETD
Restart rails after generating a new work type, if rails was running already.
-
Open a browser window and go to
http://localhost:3000
. You should be able to create an account and log in. Once you have logged in, go tohttp://localhost:3000/concern/etds/new
. You should be able to submit a new ETD object.
Sample Code
To see the sample application at this stage, go to https://github.com/RepoCamp/oxford2017/tree/1_initial_app_setup
Common Tasks
-
Start the VM if it's not running
- Open a new terminal window
- Change directory to the directory with your Vagrantfile in it
- Type
vagrant up
-
Connect to the VM
- From the directory with your Vagrantfile in it, type 'vagrant ssh`
-
Start a rails console
- Make sure you're connected to the VM
- Change directory to the root of your rails application
- Type
rails console
to enter the console (orrails c
for shorthand) - Type
exit
when you're done to return to the command line
-
Start solr, fedora, and web servers
- You'll generally want to open a separate terminal and connect to a new ssh session where you can leave the servers running
- Change directory to the root of your rails application
- Type
rails hydra:server
to start Solr, Fedora, and the Web server
-
Restart solr if you get an error like "ERROR: Core 'hydra-development' already exists!"
- Enter
rails hydra:server
a second time and the error should clear itself.
- Enter