Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding Sunspot recipe

* gets Solr 1.4.0, as well as sunspot (Newest version).
* source git://github.com/bommaritobrianmatthew/ey-cloud-recipes.git
  • Loading branch information...
commit 9df6a64aec552d098c2ba88a1bab3abb8272664e 1 parent 88de976
Scott M. Likens authored atmos committed
View
13 cookbooks/main/recipes/default.rb
@@ -1,8 +1,8 @@
-execute "testing" do
- command %Q{
- echo "i ran at #{Time.now}" >> /root/cheftime
- }
-end
+#execute "testing" do
+# command %Q{
+# echo "i ran at #{Time.now}" >> /root/cheftime
+# }
+#end
require_recipe 'postgres'
@@ -32,3 +32,6 @@
#uncomment to run the mongodb recipe
# require_recipe "mongodb"
+
+#uncomment to run the sunspot recipe
+# require_recipe "sunspot"
View
55 cookbooks/ruby-heaps-stack/recipes/default.rb
@@ -0,0 +1,55 @@
+#
+# Cookbook Name:: ruby-heaps-stack
+# Recipe:: default
+#
+
+remote_file "/usr/src/ruby-heaps-stacks.tar.gz" do
+ source "http://github.com/ice799/matzruby/tarball/heap_stacks"
+ owner "root"
+ group "root"
+ mode "0644"
+end
+
+execute "unarchive ruby" do
+ command "cd /usr/src;tar zxfv ruby-heaps-stacks.tar.gz"
+end
+
+execute "autotools" do
+ command "cd /usr/src/ice799-matzruby*;autoconf"
+end
+
+execute "libtoolize" do
+ command "cd /usr/src/ice799-matzruby*;libtoolize --force"
+end
+
+execute "autotools round 2" do
+ command "cd /usr/src/ice799-matzruby*;autoconf"
+end
+
+execute "configure" do
+ command "cd /usr/src/ice799-matzruby*;./configure --prefix=/usr --sysconfdir=/etc --enable-pthread --enable-shared"
+end
+
+execute "make" do
+ command "cd /usr/src/ice799-matzruby*;make -j1"
+end
+
+execute "make install" do
+ command "cd /usr/src/ice799-matzruby*;make install"
+end
+
+remote_file "/usr/src/rubygems.tar.gz" do
+ source "http://production.cf.rubygems.org/rubygems/rubygems-1.3.6.tgz"
+ owner "root"
+ gorup "root"
+ mode "0644"
+end
+
+execute "unarchive rubygems" do
+ source "cd /usr/src;tar zxfv rubygems-1.3.6.tgz"
+end
+
+execute "install_rubygems" do
+ execute "cd /usr/src/rubygems-1.3.6;ruby setup.rb --no-ri --no-rdoc"
+end
+
View
81 cookbooks/sunspot/recipes/default.rb
@@ -0,0 +1,81 @@
+#
+# Cookbook Name:: solr
+# Recipe:: default
+#
+
+require 'digest/sha1'
+
+node[:applications].each do |app,data|
+
+ directory "/data/#{app}/jettyapps" do
+ owner node[:owner_name]
+ group node[:owner_name]
+ mode 0755
+ recursive true
+ end
+
+ directory "/var/run/solr" do
+ owner node[:owner_name]
+ group node[:owner_name]
+ mode 0755
+ recursive true
+ end
+
+ template "/engineyard/bin/solr" do
+ source "solr.erb"
+ owner node[:owner_name]
+ group node[:owner_name]
+ mode 0755
+ variables({
+ :rails_env => node[:environment][:framework_env],
+ :app => app
+ })
+ end
+
+ template "/etc/monit.d/solr.#{app}.monitrc" do
+ source "solr.monitrc.erb"
+ owner node[:owner_name]
+ group node[:owner_name]
+ mode 0644
+ variables({
+ :app => app,
+ :user => node[:owner_name],
+ :group => node[:owner_name]
+ })
+ end
+
+ execute "install solr example package" do
+ user node[:owner_name]
+ group node[:owner_name]
+ command("if [ ! -e /data/#{app}/jettyapps/solr ]; then cd /data/#{app}/jettyapps && " +
+ "wget -O apache-solr-1.4.0.tgz http://mirror.cc.columbia.edu/pub/software/apache/lucene/solr/1.4.0/apache-solr-1.4.0.tgz && " +
+ "tar -xzf apache-solr-1.4.0.tgz && " +
+ "mv apache-solr-1.4.0/example solr && " +
+ "rm -rf apache-solr-1.4.0; fi")
+ action :run
+ end
+
+ gem_package "sunspot_rails" do
+ source "http://gemcutter.org"
+ action :install
+ end
+
+ gem_package "nokogiri" do
+ source "http://gemcutter.org"
+ action :install
+ end
+
+ execute "install-sunspot-solr" do
+ user node[:owner_name]
+ group node[:owner_name]
+ command "sunspot-installer -f /data/#{app}/jettyapps/solr/solr"
+ action :run
+ end
+
+ execute "restart-monit-solr" do
+ command "/usr/bin/monit reload && " +
+ "/usr/bin/monit restart all -g solr_#{app}"
+ action :run
+ end
+
+end
View
47 cookbooks/sunspot/templates/default/solr.erb
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# This script starts and stops the solr server
+# This script belongs in /engineyard/bin/solr
+#
+PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
+RAILS_ENV=<%= @rails_env %>; export RAILS_ENV
+
+usage() {
+ echo "Usage: $0 #{@app} {start, stop}"
+ exit 1
+}
+
+if [ $# -lt 2 ]; then usage; fi
+
+if [ -d /data/$1/jettyapps/solr ]; then
+cd /data/$1/jettyapps/solr
+ mkdir -p /var/log/engineyard/solr/$1
+
+ # handle the second param, don't start if already existing
+ case "$2" in
+ start)
+ echo "Starting the Solr server."
+ if [ -f /var/run/solr/$1.pid ]; then
+PID=`cat /var/run/solr/$1.pid`
+ if [ ! -d /proc/$PID ]; then
+rm -f /var/run/solr/$1.pid
+ fi
+fi
+
+nohup java -Djava.net.preferIPv4Stack=true -Dsolr.solr.home=solr -jar start.jar >> /var/log/engineyard/solr/$1.log 2>> /var/log/engineyard/solr/$1.err.log &
+ echo $! > /var/run/solr/$1.pid
+ ;;
+ stop)
+ echo "Stopping the solr server."
+ if [ -f /var/run/solr/$1.pid ]; then
+kill -9 `cat /var/run/solr/$1.pid` 2>/dev/null; true
+fi
+ ;;
+ *)
+ usage
+ ;;
+ esac
+else
+echo "/data/$1/jettyapps/solr doesn't exist."
+ usage
+fi
View
6 cookbooks/sunspot/templates/default/solr.monitrc.erb
@@ -0,0 +1,6 @@
+check process solr_<%= @app %>_9080
+ with pidfile /var/run/solr/<%= @app %>.pid
+ start program = "/engineyard/bin/solr <%= @app %> start" as uid <%= @user %> and gid <%= @group %>
+ stop program = "/engineyard/bin/solr <%= @app %> stop" as uid <%= @user %> and gid <%= @group %>
+ if totalmem is greater than 192 MB for 2 cycles then restart # eating up memory?
+ group solr_<%= @app %>
Please sign in to comment.
Something went wrong with that request. Please try again.