Class: ASpaceEnvironment
- Inherits:
-
Object
- Object
- ASpaceEnvironment
- Defined in:
- backend/app/lib/bootstrap.rb
Class Method Summary collapse
-
.demo_db? ⇒ Boolean
-
.environment ⇒ Object
-
.init(environment = :auto) ⇒ Object
-
.prepare_database ⇒ Object
Class Method Details
.demo_db? ⇒ Boolean
63 64 65 |
# File 'backend/app/lib/bootstrap.rb', line 63 def self.demo_db? AppConfig[:db_url] =~ /aspacedemo=true/ end |
.environment ⇒ Object
44 45 46 |
# File 'backend/app/lib/bootstrap.rb', line 44 def self.environment @environment end |
.init(environment = :auto) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'backend/app/lib/bootstrap.rb', line 49 def self.init(environment = :auto) return if @environment # Already initialised if environment != :auto @environment = environment elsif ENV["ASPACE_INTEGRATION"] == "true" @environment = :integration else @environment = :production end prepare_database end |
.prepare_database ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'backend/app/lib/bootstrap.rb', line 67 def self.prepare_database if @environment == :integration && demo_db? # For integration, use an in-memory database instead. AppConfig[:db_url] = "jdbc:derby:memory:integrationdb;create=true;aspacedemo=true" end if @environment != :unit_test FileUtils.mkdir_p(AppConfig[:data_directory]) if demo_db? # Try to discourage Derby from locking whole tables. java.lang.System.set_property("derby.locks.escalationThreshold", "2147483647") Sequel.connect(AppConfig[:db_url]) do |db| puts "Running database migrations for demo database" DBMigrator.setup_database(db) puts "All done." end puts " \n ************************************************************************\n ***\n *** WARNING: Running against the demo database, which is not intended\n *** for production use.\n ***\n *** Please see the README.md file for instructions on configuring MySQL.\n ***\n ************************************************************************\n \n EOF\n end\n end\n end\n\nend\n" |