Either using brew
, or via rbenv.
To avoid issues with gem installation, configure gem
with --no-ri
. Here is a sample ~/.gemrc
that has some sensible settings:
install: --no-rdoc --no-ri --env-shebang
update: --no-rdoc --no-ri --env-shebang
verbose: true
update_sources: true
sources:
- http://rubygems.org/
backtrace: false
bulk_threshold: 1000
benchmark: false
brew install rabbitmq
Then read what it says about loading with launchctl
, and do it.
brew install memcached
Then read what it says about loading with launchctl
, and do it.
Don't have anything running on port 80, or 8080 and upwards.
git clone https://github.com/t11e/grove.git
git checkout -b consolidated_pull_requests origin/consolidated_pull_requests # Need this branch at the moment
bundle install
createuser -SdP grove
cp config/database-example.yml config/database.yml
# Now edit database.yml with the password you set with `createuser`
createdb -O grove grove_development
bundle exec rake db:migrate
bundle exec rake db:test:prepare
rspec
git clone https://github.com/bengler/checkpoint.git
bundle install
createuser -SdP checkpoint
cp config/database-example.yml config/database.yml
# Now edit database.yml with the password you set with `createuser`
createdb -O checkpoint checkpoint_development
bundle exec rake db:migrate
bundle exec rake db:test:prepare
rspec
git clone https://github.com/atombender/brow.git
cd brow
git checkout -b localdev_hack origin/localdev_hack # This is the most correct branch at the moment
bundle install
cd brow; rake install
Nginx needs the gzip module, so edit /usr/local/Library/Formula/nginx.rb
and find the args = [...
line, and add:
"--with-http_stub_status_module"
at the bottom of the array. Then:
brew install --build-from-source nginx
brew install haproxy
See if you have lsof
installed (by running which lsof
). If not, you will have to do:
brew install lsof
mkdir ~/.brow
cd ~/dev # Or wherever you keep your stuff
ln -s $PWD/grove ~/.brow/
ln -s $PWD/checkpoint ~/.brow/
echo "? [S Sender bengler] [<= Level debug] file /var/log/system.log" | sudo tee -a /etc/asl.conf
sudo pkill -f syslogd
Watch system.log for output from Unicorn and apps.
brow up
If you get a permission error about /etc/hosts
, you will have to chmod a+w /etc/hosts
. :-(
To create a Checkpoint "session key", which acts like an API key in many places (including Grove), you need to cheat a little bit, because Checkpoint itself does not have an API to do it.
To do this, create a script create_session_key.rb
in the root of the Checkpoint project:
require './config/environment'
realm_name = ARGV.shift
abort "Specify realm name" unless realm_name
realm = Realm.where(label: realm_name).first
realm ||= Realm.create!(label: realm_name)
realm.service_keys = {
google_oauth2: {
client_id: 'ADD KEY HERE',
client_secret: 'ADD SECRET HERE'
}
}
realm.save!
domain = Domain.where(name: 'homesdotcom.dev').first
domain ||= Domain.create!(name: 'homesdotcom.dev', realm: realm)
realm.primary_domain = domain
realm.save!
domain = Domain.where(name: 'development-homes.t11e.com').first
domain ||= Domain.create!(name: 'development-homes.t11e.com', realm: realm)
identity = Identity.where(realm_id: realm.id, god: true).first
identity ||= Identity.create!(god: true, realm: realm)
session = identity.sessions.first
session ||= Session.create!(identity: identity)
puts session.key
Run this with:
bundle exec ruby create_session_key.rb endeavor-homes
Now you have a special privileged ("god") identity and a session key for it.
To make testing simpler, add homesdotcom.dev
to your /etc/hosts
, pointing to 127.0.0.1.
Try posting a document (replace the key with your key):
export KEY=<key>
curl -vs -XPOST -b "checkpoint.session=$KEY" \
-H "Content-Type: application/json" \
-d'{"post":{"title": "Hello world"}}' \
"http://grove.dev/api/grove/v1/posts/post.ad:homesdotcom.ads"
It should output a document with a uid
field. The uid
field should be something like post.ad:homesdotcom.ads$1
. Now you can retrieve it by the same UID:
curl -vs -b "checkpoint.session=$KEY" \
"http://grove.dev/api/grove/v1/posts/post.ad:homesdotcom.ads$1"
Remember to replace your key below. Put this in the Grove root to make it easier to run (needs the pebblebed
gem).
require 'pp'
require 'pebblebed'
Pebblebed.config do
host 'homesdotcom.dev'
service :checkpoint
service :grove
end
key = '<key>'
pebblebed = ::Pebblebed::Connector.new(key, {})
grove = pebblebed.grove
posts = grove.get('/posts/post.ad:homesdotcom.ads', limit: 100)['posts']
posts.each do |post|
pp post.to_hash
end
grove.post('/posts/post.ad:homesdotcom.ads', {
post: {
document: {
title: "This is a test. #{Time.now}"
}
}
})