Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Commit

Permalink
Add a script to start mongodb instances for jruby
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Schirp committed Oct 5, 2011
1 parent d689c2e commit 2b84bcc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions script/mongodb.rb
@@ -0,0 +1,24 @@
#!/usr/bin/env ruby

require 'fileutils'

tmpdir = File.expand_path(File.join(File.dirname(__FILE__),'..','tmp'))
dbpath = File.join(tmpdir,'mongodb')

if File.exists? dbpath
puts "removing dbpath: #{dbpath}"
FileUtils.rm_rf dbpath
end

unless File.exists? dbpath
puts "creating dbpath: #{dbpath}"
FileUtils.mkdir_p dbpath
end

command = %W(mongod -dbpath #{dbpath} -noprealloc -nojournal -noauth -port 26016 -bind_ip 127.0.0.1)

puts "executing: #{command.join(' ')}"
puts '************************************************************'
puts 'Run specs: $ MONGO_URL=mongo://127.0.0.1:26016 bundle exec spec spec'
puts '************************************************************'
Kernel.exec *command
2 changes: 2 additions & 0 deletions spec/lib/connection_helper.rb
Expand Up @@ -15,6 +15,8 @@ def setup_connection(name = :default)
'mongo://localhost:27017/test'
elsif ENV['MONGO_URL']
ENV['MONGO_URL']
elsif RUBY_PLATFORM == 'java'
raise 'Automatic mongodb management is not possible under jruby pls provide a MONGO_URL env variable'
else
mongod_start name
mongod_wait name
Expand Down

0 comments on commit 2b84bcc

Please sign in to comment.