Skip to content

Instantly share code, notes, and snippets.

@mark-cooper
Last active November 5, 2024 00:35
Show Gist options
  • Save mark-cooper/0fb03183feddacc9dc0fc19c675df71e to your computer and use it in GitHub Desktop.
Save mark-cooper/0fb03183feddacc9dc0fc19c675df71e to your computer and use it in GitHub Desktop.
Load ArchivesSpace backend in a pry session
#!/bin/bash
# SETUP: requires rbenv
# rbenv install jruby-9.4.8.0 && rbenv local jruby-9.4.8.0 && gem install bundler pry
# docker-compose -f docker-compose-dev.yml build
# docker-compose -f docker-compose-dev.yml up --detach
# ./build/run bootstrap && ./build/run db:migrate
# chmod u+x ./ascli
# ./ascli
export ASCLI_RUNNER=${1:-rbenv}
export ASPACE_ENV=development
export RUBYLIB=$PWD/common/
export CLASSPATH=$PWD/build/*:$PWD/common/lib/*
export GEM_HOME=$PWD/build/gems/jruby/3.1.0/gems
export BUNDLE_BIN_PATH=/build/gems/jruby/3.1.0/bin
export BUNDLE_PATH=$GEM_HOME
export BUNDLE_GEMFILE=$PWD/backend/Gemfile
JAVA_OPTS="$JAVA_OPTS -Daspace.config.db_url=jdbc:mysql://127.0.0.1:3306/archivesspace?useUnicode=true&characterEncoding=UTF-8&user=as&password=as123&useSSL=false&allowPublicKeyRetrieval=true"
JAVA_OPTS="$JAVA_OPTS -Daspace.config.search_user_secret=devserver -Daspace.config.public_user_secret=devserver"
JAVA_OPTS="$JAVA_OPTS -Daspace.config.staff_user_secret=devserver -Daspace.config.frontend_cookie_secret=devserver"
JAVA_OPTS="$JAVA_OPTS -Daspace.config.public_cookie_secret=devserver -Daspace.config.solr_url=http://localhost:8983/solr/archivesspace"
JAVA_OPTS="$JAVA_OPTS -Daspace.config.data_directory=$PWD/build -Dfile.encoding=UTF-8 -Daspace.devserver=true"
JAVA_OPTS="$JAVA_OPTS -Xmx512m -Xss512m"
export JAVA_OPTS
PATH=$(dirname $($ASCLI_RUNNER which gem)):$PATH
ruby -e 'puts $:'
bundle install
# for the webserver
bundle exec jruby -I ./common/ ./backend/app/main.rb
# for the console
# bundle exec pry -I ./common/ -r ./backend/app/main.rb
# RequestContext.open(repo_id: 2) { Accession.find(1) }
@mark-cooper
Copy link
Author

Also needed:

diff --git a/backend/Gemfile b/backend/Gemfile
index 28f30f2da..d69be2786 100644
--- a/backend/Gemfile
+++ b/backend/Gemfile
@@ -45,6 +45,7 @@ group :development do
   gem 'pry'
   gem 'pry-debugger-jruby'
   gem 'pry-nav'
+  gem 'puma'
 end

And:

diff --git a/backend/app/main.rb b/backend/app/main.rb
index 7abb7c3cb..f93cc718b 100644
--- a/backend/app/main.rb
+++ b/backend/app/main.rb
@@ -91,7 +91,7 @@ class ArchivesSpaceService < Sinatra::Base
     config.dont_reload File.join("**", "spec", "*.rb")
     config.dont_reload File.join("..", "plugins", "**", "spec", "*.rb")
 
-    set :server, :mizuno
+    set :server, :puma
     set :server_settings, {:reuse_address => true}
   end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment