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

  1. Start your VM using vagrant up and connect with vagrant ssh.

  2. Navigate to your working directory - /vagrant will give you a VM mounted instance of the directory from which you started vagrant

    cd /vagrant
    
  3. 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

    1. Run rails _5.1.2_ new hyrax-demo
    2. cd hyrax-demo
    3. Add gem 'hyrax', '~> 2.0.0.rc2' to your Gemfile
    4. bundle install
    5. rails g hyrax:install -f
    6. rails db:migrate
  4. Change directory to the root of the newly generated application

    cd hyrax-demo
    
  5. 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
    
  6. Point your solr config at the local (already downloaded) solr instance in /var/tmp by adding these lines to the top of hyrax-demo/.solr_wrapper:

    version: 6.6.2
    download_dir: /var/tmp
    
  7. Point your fedora config at the local (already downloaded) fedora instance in /var/tmp by adding these lines to the end of hyrax-demo/.fcrepo_wrapper:

    version: 4.7.4
    download_dir: /var/tmp
    
  8. 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.

  9. Generate the default admin set:

    rails hyrax:default_admin_set:create
    
  10. 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.

  11. 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 to http://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

    1. Open a new terminal window
    2. Change directory to the directory with your Vagrantfile in it
    3. Type vagrant up
  • Connect to the VM

    1. From the directory with your Vagrantfile in it, type 'vagrant ssh`
  • Start a rails console

    1. Make sure you're connected to the VM
    2. Change directory to the root of your rails application
    3. Type rails console to enter the console (or rails c for shorthand)
    4. Type exit when you're done to return to the command line
  • Start solr, fedora, and web servers

    1. You'll generally want to open a separate terminal and connect to a new ssh session where you can leave the servers running
    2. Change directory to the root of your rails application
    3. 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!"

    1. Enter rails hydra:server a second time and the error should clear itself.