Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moving everything around

git-svn-id: http://svn.ducktyper.com/capigen/trunk@59 03f83d6c-b416-495f-9003-0924d19d01a8
  • Loading branch information...
commit 397c2b0e74b6f1eabf6ced217e48b2c49ba3fbb0 1 parent 9b77d2d
@gabriel authored
Showing with 1,632 additions and 250 deletions.
  1. +8 −1 Capfile
  2. +4 −7 Rakefile
  3. +5 −0 generators/capistrano/USAGE
  4. +51 −0 generators/capistrano/capistrano_generator.rb
  5. +17 −0 generators/templates/centos/setup.sh
  6. +95 −0 generators/templates/centos/sudoers
  7. +20 −0 generators/templates/imagemagick/install.sh
  8. +27 −0 generators/templates/memcached/install.sh
  9. +70 −0 generators/templates/memcached/memcached.initd.centos.erb
  10. +4 −0 generators/templates/memcached/memcached.monitrc.erb
  11. +61 −0 generators/templates/mongrel/mongrel_cluster.initd.erb
  12. +15 −0 generators/templates/mongrel/mongrel_cluster.monitrc.erb
  13. +10 −0 generators/templates/mongrel/mongrel_cluster.yml.erb
  14. +14 −0 generators/templates/monit/cert.sh
  15. +29 −0 generators/templates/monit/install.sh
  16. +34 −0 generators/templates/monit/monit.cnf
  17. +68 −0 generators/templates/monit/monit.initd.centos.erb
  18. +28 −0 generators/templates/monit/monitrc.erb
  19. +15 −0 generators/templates/monit/patch_inittab.sh
  20. +10 −0 generators/templates/mysql/install.sh.erb
  21. +5 −0 generators/templates/mysql/install_db.sql.erb
  22. +6 −0 generators/templates/mysql/mysql.monitrc.erb
  23. +42 −0 generators/templates/nginx/install.sh.erb
  24. +76 −0 generators/templates/nginx/nginx.conf.erb
  25. +62 −0 generators/templates/nginx/nginx.initd.erb
  26. +4 −0 generators/templates/nginx/nginx.monitrc.erb
  27. +94 −0 generators/templates/nginx/nginx_vhost.conf.erb
  28. +42 −0 generators/templates/rails/database.yml.erb
  29. +26 −0 generators/templates/ruby/ruby_install.sh
  30. +13 −0 generators/templates/ruby/rubygems_install.sh
  31. +22 −0 generators/templates/sphinx/install.sh.erb
  32. +496 −0 generators/templates/sphinx/sphinx.conf.erb
  33. +4 −0 generators/templates/sphinx/sphinx.monitrc.erb
  34. +67 −0 generators/templates/sphinx/sphinx_app.initd.centos.erb
  35. +57 −0 generators/templates/sphinx/sphinx_app.initd.erb
  36. +0 −1  init.rb
  37. +0 −9 recipes/aspell.rb
  38. +0 −8 recipes/gems.rb
  39. +2 −4 recipes/imagemagick.rb
  40. +3 −14 recipes/install.rb
  41. +4 −18 recipes/memcached.rb
  42. +1 −6 recipes/mongrel_cluster.rb
  43. +5 −37 recipes/monit.rb
  44. +5 −20 recipes/mysql.rb
  45. +6 −16 recipes/nginx.rb
  46. +0 −32 recipes/profiles/centos-sick.yml
  47. +0 −15 recipes/profiles/centos-test.yml
  48. +2 −3 recipes/ruby.rb
  49. +2 −18 recipes/sphinx.rb
  50. +0 −32 tasks/configr.rake
  51. +1 −9 test/test_helper.rb
View
9 Capfile
@@ -1,3 +1,7 @@
+#
+# Capfile for running base install recipe
+#
+
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
# Patches for capistrano
@@ -12,4 +16,7 @@ require 'erb'
set :user, Proc.new { Capistrano::CLI.ui.ask('Bootstrap user: ') }
# Roles
-role :app, Capistrano::CLI.ui.ask('Server: ')
+role :base, Capistrano::CLI.ui.ask('Server: ')
+
+
+set :profile, Proc.new { load choose_profile }
View
11 Rakefile
@@ -1,7 +1,4 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-RAILS_ROOT = File.dirname(__FILE__) + "/test"
-
-Dir["tasks/*"].each { |task| load task }
+require 'config/requirements'
+require 'config/hoe' # setup Hoe + all gem configuration
+
+Dir['tasks/**/*.rake'].each { |rake| load rake }
View
5 generators/capistrano/USAGE
@@ -0,0 +1,5 @@
+Description:
+
+
+Usage:
+
View
51 generators/capistrano/capistrano_generator.rb
@@ -0,0 +1,51 @@
+class CapistranoGenerator < RubiGen::Base
+
+ default_options :author => nil
+
+ attr_reader :name
+
+ def initialize(runtime_args, runtime_options = {})
+ super
+ usage if args.empty?
+ @name = args.shift
+ extract_options
+ end
+
+ def manifest
+ record do |m|
+ # Ensure appropriate folder(s) exists
+ m.directory 'some_folder'
+
+ # Create stubs
+ # m.template "template.rb", "some_file_after_erb.rb"
+ # m.file "file", "some_file_copied"
+ end
+ end
+
+ protected
+ def banner
+ <<-EOS
+Creates a ...
+
+USAGE: #{$0} #{spec.name} name"
+EOS
+ end
+
+ def add_options!(opts)
+ # opts.separator ''
+ # opts.separator 'Options:'
+ # For each option below, place the default
+ # at the top of the file next to "default_options"
+ # opts.on("-a", "--author=\"Your Name\"", String,
+ # "Some comment about this option",
+ # "Default: none") { |options[:author]| }
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
+ end
+
+ def extract_options
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
+ # Templates can access these value via the attr_reader-generated methods, but not the
+ # raw instance variable value.
+ # @author = options[:author]
+ end
+end
View
17 generators/templates/centos/setup.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+trap ERROR ERR
+
+# Add admin group
+cat /etc/group | grep admin || /usr/sbin/groupadd admin
+
+# Install sudoers
+install -o root -m 440 /tmp/sudoers /etc/sudoers
+
+# Change inittab to runlevel 3
+sed -i -e 's/^id:5:initdefault:/id:3:initdefault:/g' /etc/inittab
+
+
+# Create web apps directory
+mkdir -p /var/www/apps
View
95 generators/templates/centos/sudoers
@@ -0,0 +1,95 @@
+## Sudoers allows particular users to run various commands as
+## the root user, without needing the root password.
+##
+## Examples are provided at the bottom of the file for collections
+## of related commands, which can then be delegated out to particular
+## users or groups.
+##
+## This file must be edited with the 'visudo' command.
+
+## Host Aliases
+## Groups of machines. You may prefer to use hostnames (perhap using
+## wildcards for entire domains) or IP addresses instead.
+# Host_Alias FILESERVERS = fs1, fs2
+# Host_Alias MAILSERVERS = smtp, smtp2
+
+## User Aliases
+## These aren't often necessary, as you can use regular groups
+## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
+## rather than USERALIAS
+# User_Alias ADMINS = jsmith, mikem
+
+
+## Command Aliases
+## These are groups of related commands...
+
+## Networking
+Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool
+
+## Installation and management of software
+Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum
+
+## Services
+Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig
+
+## Updating the locate database
+Cmnd_Alias LOCATE = /usr/sbin/updatedb
+
+## Storage
+Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount
+
+## Delegating permissions
+Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp
+
+## Processes
+Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall
+
+## Drivers
+Cmnd_Alias DRIVERS = /sbin/modprobe
+
+# Defaults specification
+
+#
+# Disable "ssh hostname sudo <cmd>", because it will show the password in clear.
+# You have to run "ssh -t hostname sudo <cmd>".
+#
+#Defaults requiretty
+
+Defaults env_reset
+Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
+ LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
+ LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
+ LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
+ _XKB_CHARSET XAUTHORITY"
+
+## Next comes the main part: which users can run what software on
+## which machines (the sudoers file can be shared between multiple
+## systems).
+## Syntax:
+##
+## user MACHINE=COMMANDS
+##
+## The COMMANDS section may have other options added to it.
+##
+## Allow root to run any commands anywhere
+root ALL=(ALL) ALL
+%admin ALL=(ALL) ALL
+
+## Allows members of the 'sys' group to run networking, software,
+## service management apps and more.
+# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
+
+## Allows people in group wheel to run all commands
+# %wheel ALL=(ALL) ALL
+
+## Same thing without a password
+# %wheel ALL=(ALL) NOPASSWD: ALL
+
+## Allows members of the users group to mount and unmount the
+## cdrom as root
+# %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
+
+## Allows members of the users group to shutdown this system
+# %users localhost=/sbin/shutdown -h now
+
View
20 generators/templates/imagemagick/install.sh
@@ -0,0 +1,20 @@
+#! /bin/sh
+
+set -e
+trap ERROR ERR
+
+cd /tmp
+
+wget -nv ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
+
+tar zxpf ImageMagick.tar.gz
+cd ImageMagick-*
+echo "Configuring ImageMagick..."
+./configure > configure.log
+echo "Compiling ImageMagick..."
+make > make.log
+echo "Installing ImageMagick..."
+make install > make_install.log
+
+cd ..
+rm -rf ImageMagick*
View
27 generators/templates/memcached/install.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -e
+trap ERROR ERR
+
+cd /tmp
+
+wget -nv http://www.danga.com/memcached/dist/memcached-1.2.4.tar.gz
+
+tar zxpf memcached-1.2.4.tar.gz
+
+cd memcached-1.2.4
+echo "Configuring memcached..."
+./configure --prefix=/usr/local > configure.log
+echo "Compiling memcached..."
+make > make.log
+echo "Installing memcached..."
+make install > make_install.log
+
+cd ..
+rm -rf memcached-1.2.4*
+
+install -o root /tmp/memcached.initd /etc/init.d/memcached
+rm -f /tmp/memcached.initd
+/sbin/chkconfig --level 345 memcached on
+
+
View
70 generators/templates/memcached/memcached.initd.centos.erb
@@ -0,0 +1,70 @@
+#! /bin/sh
+# memcached: Memcached
+#
+# chkconfig: - 86 14
+# description: memcached
+# processname: memcached
+#
+# Author: Gabriel Handford http://ducktyper.com
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+RETVAL=0
+
+DESC="memcached"
+NAME="memcached"
+DAEMON=/usr/local/bin/memcached
+PIDFILE=<%= memcached_pid_path %>
+MEM=<%= memcached_memory %>
+PORT=<%= memcached_port %>
+# Have to be root in order to save in /var/run
+USER=root
+
+start() {
+ daemon $DAEMON -d -m $MEM -p $PORT -u $USER -P $PIDFILE
+ RETVAL=$?
+ echo
+ return $RETVAL;
+}
+
+stop() {
+ kill -QUIT `cat $PIDFILE` || echo -n " not running"
+}
+
+reload() {
+ kill -HUP `cat $PIDFILE` || echo -n " can't reload"
+}
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: $NAME"
+ start
+ RETVAL=$?;
+ ;;
+ stop)
+ echo "Stopping $DESC: $NAME"
+ stop
+ RETVAL=$?;
+ ;;
+ reload)
+ echo -n "Reloading $DESC configuration..."
+ reload
+ RETVAL=$?;
+ echo "reloaded."
+ ;;
+ restart)
+ echo -n "Restarting $DESC: $NAME"
+ stop
+ # Sleep after stop
+ sleep 1
+ start
+ RETVAL=$?;
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|force-reload}" >&2
+ RETVAL=3;
+ ;;
+esac
+
+exit $RETVAL;
View
4 generators/templates/memcached/memcached.monitrc.erb
@@ -0,0 +1,4 @@
+check process memcached with pidfile <%= memcached_pid_path %>
+ start program = "/sbin/service memcached start"
+ stop program = "/sbin/service memcached stop"
+ if failed host 127.0.0.1 port <%= memcached_port %> then restart
View
61 generators/templates/mongrel/mongrel_cluster.initd.erb
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
+#
+# mongrel_cluster_<%= application %> Startup script for Mongrel clusters (<%= application %>)
+#
+# chkconfig: - 85 15
+# description: mongrel_cluster_<%= application %> manages multiple Mongrel processes for use \
+# behind a load balancer.
+#
+# Modified by: Gabriel Handford http://ducktyper.com
+#
+
+set -e
+trap ERROR ERR
+
+CONF_DIR=<%= mongrel_config_path %>
+PID_DIR=<%= pid_path %>
+USER=<%= user %>
+
+RETVAL=0
+
+fail() {
+ echo "Failed to start: $1"
+ exit 1
+}
+
+# Gracefully exit if the controller is missing.
+which mongrel_cluster_ctl >/dev/null || fail "mongrel_cluster_ctl not found"
+
+# Go no further if config directory is missing.
+[ -d "$CONF_DIR" ] || fail "$CONF_DIR not found"
+
+case "$1" in
+ start)
+ # Create pid directory
+ mkdir -p $PID_DIR
+ chown $USER:$USER $PID_DIR
+
+ mongrel_cluster_ctl start -c $CONF_DIR --clean
+ RETVAL=$?
+ ;;
+ stop)
+ mongrel_cluster_ctl stop -c $CONF_DIR
+ RETVAL=$?
+ ;;
+ restart)
+ mongrel_cluster_ctl restart -c $CONF_DIR
+ RETVAL=$?
+ ;;
+ status)
+ mongrel_cluster_ctl status -c $CONF_DIR
+ RETVAL=$?
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+
+exit $RETVAL
View
15 generators/templates/mongrel/mongrel_cluster.monitrc.erb
@@ -0,0 +1,15 @@
+<% processes.each do |process| %>
+
+check process mongrel_cluster_<%= application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
+ group mongrel_cluster_<%= application %>
+ start program = "<%= process[:name] %> start <%= process[:start_options] %>"
+ stop program = "<%= process[:name] %> stop <%= process[:stop_options] %>"
+ if failed host 127.0.0.1 port <%= process[:port] %> protocol http
+ and request "/" then alert
+ if totalmem > 100 Mb then restart
+ if cpu is greater than 60% for 2 cycles then alert
+ if cpu > 80% for 5 cycles then restart
+ if loadavg(5min) greater than 10 for 8 cycles then restart
+ if 3 restarts within 5 cycles then timeout
+
+<% end %>
View
10 generators/templates/mongrel/mongrel_cluster.yml.erb
@@ -0,0 +1,10 @@
+---
+cwd: <%= current_path %>
+log_file: log/mongrel.log
+port: "<%= mongrel_port %>"
+environment: production
+address: 127.0.0.1
+pid_file: <%= pid_path %>/mongrel.pid
+servers: <%= mongrel_size %>
+user: <%= user %>
+group: <%= user %>
View
14 generators/templates/monit/cert.sh
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+set -e
+trap ERROR ERR
+
+mkdir -p /var/certs
+mv /tmp/monit.cnf /var/certs/monit.cnf
+
+echo "Generating PEM..."
+openssl req -new -x509 -days 365 -nodes -config /var/certs/monit.cnf -out /var/certs/monit.pem -keyout /var/certs/monit.pem -batch > debug_req.log
+openssl gendh 512 >> /var/certs/monit.pem
+echo "Generating x509..."
+openssl x509 -subject -dates -fingerprint -noout -in /var/certs/monit.pem > debug_x509.log
+chmod 700 /var/certs/monit.pem
View
29 generators/templates/monit/install.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+set -e
+trap ERROR ERR
+
+cd /tmp
+
+wget -nv http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz
+
+tar zxpf monit-4.10.1.tar.gz
+
+cd monit-4.10.1
+echo "Configuring monit..."
+./configure > configure.log
+echo "Compiling monit..."
+make > make.log
+echo "Installing monit..."
+make install > make_install.log
+
+cd ..
+rm -rf monit-4.10.1*
+
+mkdir -p /etc/monit
+
+install -o root -m 700 /tmp/monitrc /etc/monitrc
+rm -f /tmp/monitrc
+
+install -o root /tmp/monit.initd /etc/init.d/monit
+rm -f /tmp/monit.initd
View
34 generators/templates/monit/monit.cnf
@@ -0,0 +1,34 @@
+# create RSA certs - Server
+
+RANDFILE = /var/certs/openssl.rnd
+
+[ req ]
+default_bits = 1024
+encrypt_key = yes
+distinguished_name = req_dn
+x509_extensions = cert_type
+
+[ req_dn ]
+countryName = Country Name (2 letter code)
+countryName_default = US
+
+stateOrProvinceName = State or Province Name (full name)
+stateOrProvinceName_default = Washington DC
+
+localityName = Locality Name (eg, city)
+localityName_default = Washington DC
+
+organizationName = Organization Name (eg, company)
+organizationName_default = Revolution
+
+organizationalUnitName = Organizational Unit Name (eg, section)
+organizationalUnitName_default = Ninjas
+
+commonName = Common Name (FQDN of your server)
+commonName_default = localhost
+
+emailAddress = Email Address
+emailAddress_default = gabrielh@gmail.com
+
+[ cert_type ]
+nsCertType = server
View
68 generators/templates/monit/monit.initd.centos.erb
@@ -0,0 +1,68 @@
+#! /bin/sh
+# monit: Monit
+#
+# chkconfig: - 86 14
+# description: monit
+# processname: monit
+#
+# Author: Gabriel Handford http://ducktyper.com
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+RETVAL=0
+
+DESC="monit"
+NAME=monit
+DAEMON=/usr/local/bin/monit
+CONFFILE=/etc/monitrc
+LOGFILE=/var/log/monit.log
+PIDFILE=/var/run/monit.pid
+
+start() {
+ daemon $DAEMON -l $LOGFILE -p $PIDFILE -c $CONFFILE
+ RETVAL=$?
+ echo
+ return $RETVAL;
+}
+
+stop() {
+ kill -QUIT `cat $PIDFILE` || echo -n " not running"
+}
+
+reload() {
+ kill -HUP `cat $PIDFILE` || echo -n " can't reload"
+}
+
+case "$1" in
+ start)
+ #echo -n "Starting $DESC: $NAME"
+ start
+ RETVAL=$?;
+ ;;
+ stop)
+ echo "Stopping $DESC: $NAME"
+ stop
+ RETVAL=$?;
+ ;;
+ reload)
+ echo -n "Reloading $DESC configuration..."
+ reload
+ RETVAL=$?;
+ echo "reloaded."
+ ;;
+ restart)
+ echo -n "Restarting $DESC: $NAME"
+ stop
+ # Sleep after stop
+ sleep 1
+ start
+ RETVAL=$?;
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|force-reload}" >&2
+ RETVAL=3;
+ ;;
+esac
+
+exit $RETVAL;
View
28 generators/templates/monit/monitrc.erb
@@ -0,0 +1,28 @@
+set daemon 60
+set logfile syslog facility log_daemon
+set mailserver localhost
+set mail-format { from: monit@localhost }
+set alert root@localhost
+
+# Http settings
+# ---------------------------
+
+set httpd port <%= monit_port %>
+ ssl enable
+ pemfile /var/certs/monit.pem
+ allow admin:<%= monit_password %>
+
+# Core processes
+# ---------------------------
+
+check process sshd with pidfile /var/run/sshd.pid
+ start program "/sbin/service sshd start"
+ stop program "/sbin/service sshd stop"
+ if failed port 22 protocol ssh then restart
+ if 5 restarts within 5 cycles then timeout
+
+
+# Includes
+# ---------------------------
+
+include /etc/monit/*.monitrc
View
15 generators/templates/monit/patch_inittab.sh
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+set -e
+trap ERROR ERR
+
+NO_MONIT=0
+grep -q monit /etc/inittab > /dev/null || export NO_MONIT=1
+
+if [ $NO_MONIT == 1 ]; then
+ echo "Patching inittab with monit..."
+ echo "" >> /etc/inittab
+ echo "# Run monit in standard run-levels" >> /etc/inittab
+ echo "mo:345:respawn:/usr/local/bin/monit -Ic /etc/monitrc -l /var/log/monit.log -p /var/run/monit.pid" >> /etc/inittab
+ telinit q
+fi
View
10 generators/templates/mysql/install.sh.erb
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+set -e
+trap ERROR ERR
+
+/sbin/chkconfig --level 345 mysqld on
+
+/sbin/service mysqld start
+
+/usr/bin/mysqladmin -u root password <%= mysql_admin_password %>
View
5 generators/templates/mysql/install_db.sql.erb
@@ -0,0 +1,5 @@
+<% locations_for_grant.each do |location| %>
+GRANT ALL PRIVILEGES ON <%= db_name %>.* TO '<%= db_user %>'@'<%= location %>' IDENTIFIED BY '<%= db_pass %>';
+<% end %>
+
+CREATE DATABASE IF NOT EXISTS <%= db_name %>;
View
6 generators/templates/mysql/mysql.monitrc.erb
@@ -0,0 +1,6 @@
+check process mysql with pidfile <%= mysql_pid_path %>
+ group database
+ start program = "/sbin/service mysqld start"
+ stop program = "/sbin/service mysqld stop"
+ if failed host 127.0.0.1 port <%= db_port %> then restart
+ if 5 restarts within 5 cycles then timeout
View
42 generators/templates/nginx/install.sh.erb
@@ -0,0 +1,42 @@
+#! /bin/bash
+
+set -e
+trap ERROR ERR
+
+BIN_PATH=<%= nginx_bin_path %>
+CONF_PATH=<%= nginx_conf_path %>
+PID_PATH=<%= nginx_pid_path %>
+ERROR_LOG_PATH=/var/log/nginx_master_error.log
+LOCK_PATH=/var/lock/nginx
+PREFIX_PATH=<%= nginx_prefix_path %>
+
+cd /tmp/nginx
+
+wget -nv http://sysoev.ru/nginx/nginx-0.5.35.tar.gz
+
+tar zxpf nginx-0.5.35.tar.gz
+
+cd nginx-0.5.35
+echo "Configuring nginx..."
+./configure --sbin-path=$BIN_PATH --conf-path=$CONF_PATH --pid-path=$PID_PATH --error-log-path=$ERROR_LOG_PATH --lock-path=$LOCK_PATH --prefix=$PREFIX_PATH --with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1 --with-http_ssl_module > configure.log
+echo "Compiling nginx..."
+make > make.log
+echo "Installing nginx"
+make install > make_install.log
+
+cd ..
+rm -rf nginx-0.5.35*
+
+install -o root /tmp/nginx.initd /etc/init.d/nginx
+rm -f /tmp/nginx.initd
+
+/sbin/chkconfig --level 345 nginx on
+
+mkdir -p /etc/nginx/vhosts
+
+echo "# Blank nginx conf; work-around for nginx conf include issue" > /etc/nginx/vhosts/blank.conf
+
+install -o root -m 644 /tmp/nginx.conf $CONF_PATH
+rm -f /tmp/nginx.conf
+
+id nginx || /usr/sbin/adduser -r nginx
View
76 generators/templates/nginx/nginx.conf.erb
@@ -0,0 +1,76 @@
+##
+# See http://brainspl.at/articles/2007/01/03/new-nginx-conf-with-optimizations
+# See http://topfunky.net/svn/shovel/nginx
+#
+
+# user and group to run as
+user nginx nginx;
+
+# number of nginx workers
+worker_processes 6;
+
+# pid of nginx master process
+pid <%= nginx_pid_path %>;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include <%= File.dirname(nginx_conf_path) %>/mime.types;
+ default_type application/octet-stream;
+
+ log_format main '$remote_addr - $remote_user [$time_local] $request '
+ '"$status" $body_bytes_sent "$http_referer" '
+ '"$http_user_agent" "$http_x_forwarded_for"';
+
+ # main access log
+ access_log /var/log/nginx_access.log main;
+
+ # main error log
+ error_log /var/log/nginx_error.log debug;
+
+ # no sendfile on OSX
+ sendfile on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ # These are good default values.
+ tcp_nopush on;
+ tcp_nodelay off;
+ # output compression saves bandwidth
+ gzip on;
+ gzip_http_version 1.0;
+ gzip_comp_level 2;
+ gzip_proxied any;
+ gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
+
+ # Auto include
+ include /etc/nginx/vhosts/*.conf;
+
+ # HTTPS server
+ #
+ #server {
+ # listen 443;
+ # server_name localhost;
+
+ # ssl on;
+ # ssl_certificate cert.pem;
+ # ssl_certificate_key cert.key;
+
+ # ssl_session_timeout 5m;
+
+ # ssl_protocols SSLv2 SSLv3 TLSv1;
+ # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
+ # ssl_prefer_server_ciphers on;
+
+ # location / {
+ # root html;
+ # index index.html index.htm;
+ # }
+ #}
+
+}
View
62 generators/templates/nginx/nginx.initd.erb
@@ -0,0 +1,62 @@
+#! /bin/sh
+# nginx Startup script for nginx
+#
+# chkconfig: - 86 14
+# description: nginx web server
+#
+# Author: Ryan Norbauer <ryan.norbauer@gmail.com>
+# Modified: Geoffrey Grosenbach http://topfunky.com
+# Modified: Gabriel Handford http://ducktyper.com
+
+set -e
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DESC="nginx daemon"
+NAME=nginx
+DAEMON=<%= nginx_bin_path %>
+CONFIGFILE=<%= nginx_conf_path %>
+PIDFILE=<%= nginx_pid_path %>
+
+# Gracefully exit if the package has been removed.
+test -x $DAEMON || exit 0
+
+start() {
+ $DAEMON -c $CONFIGFILE || echo -n " already running"
+}
+
+stop() {
+ kill -QUIT `cat $PIDFILE` || echo -n " not running"
+}
+
+reload() {
+ kill -HUP `cat $PIDFILE` || echo -n " can't reload"
+}
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: $NAME"
+ start
+ ;;
+ stop)
+ echo -n "Stopping $DESC: $NAME"
+ stop
+ ;;
+ reload)
+ echo -n "Reloading $DESC configuration..."
+ reload
+ echo "reloaded."
+ ;;
+ restart)
+ echo -n "Restarting $DESC: $NAME"
+ stop
+ # Sleep before start
+ sleep 1
+ start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}" >&2
+ exit 3
+ ;;
+esac
+
+exit 0
View
4 generators/templates/nginx/nginx.monitrc.erb
@@ -0,0 +1,4 @@
+check process nginx with pidfile <%= nginx_pid_path %>
+ group www
+ start program = "/sbin/service nginx start"
+ stop program = "/sbin/service nginx stop"
View
94 generators/templates/nginx/nginx_vhost.conf.erb
@@ -0,0 +1,94 @@
+#
+# Uses cache directory configured for public/cache
+# Re-writes url for iphone user agent to /iphone (so as not to conflict with cache)
+# TODO-gabe: Same for mobile user agents
+#
+# Redirects domain.com to www.domain.com (IMO should be the other way around; ie. www is deprecated)
+#
+
+upstream mongrel-cluster-<%= application %> {
+ <% ports.each do |port| %>
+ server 127.0.0.1:<%= port %>;
+ <% end %>
+}
+
+server {
+ # port to listen on. Can also be set to an IP:PORT.
+ listen 80;
+
+ # Set the max size for file uploads to 50Mb
+ client_max_body_size 50M;
+
+ # sets the domain[s] that this vhost server requests for
+ server_name www.<%= domain_name %>;
+
+ # doc root
+ root <%= public_path %>;
+
+ # vhost specific access log
+ access_log <%= shared_path %>/log/nginx.<%= application %>.access.log main;
+
+ # this rewrites all the requests to the maintenance.html
+ # page if it exists in the doc root. This is for capistrano's
+ # disable web task
+ if (-f $document_root/system/maintenance.html) {
+ rewrite ^(.*)$ /system/maintenance.html last;
+ break;
+ }
+
+ location / {
+ # Uncomment to allow server side includes so nginx can
+ # post-process Rails content
+ ## ssi on;
+
+ proxy_set_header X-Real-IP $remote_addr;
+
+ # needed for HTTPS
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_redirect false;
+ proxy_max_temp_file_size 0;
+
+ # For iphone unique url
+ if ($http_user_agent ~* "(iPhone|iPod)") {
+ rewrite ^/$ /iphone break;
+ proxy_pass http://mongrel-cluster-<%= application %>;
+ break;
+ }
+
+ if (-f $request_filename) {
+ break;
+ }
+
+ if (-f $document_root/cache/$uri/index.html) {
+ rewrite (.*) /cache/$1/index.html break;
+ }
+
+ if (-f $document_root/cache/$uri.html) {
+ rewrite (.*) /cache/$1.html break;
+ }
+
+ if (-f $document_root/cache/$uri) {
+ rewrite (.*) /cache/$1 break;
+ }
+
+ if (!-f $request_filename) {
+ proxy_pass http://mongrel-cluster-<%= application %>;
+ break;
+ }
+ }
+
+ #error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /500.html;
+ location = /500.html {
+ root <%= public_path %>;
+ }
+}
+
+server {
+ server_name <%= domain_name %>;
+ rewrite ^/(.*) http://www.<%= domain_name %>/$1 permanent;
+}
View
42 generators/templates/rails/database.yml.erb
@@ -0,0 +1,42 @@
+# MySQL (default setup). Versions 4.1 and 5.0 are recommended.
+#
+# Install the MySQL driver:
+# gem install mysql
+# On Mac OS X:
+# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
+# On Mac OS X Leopard:
+# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
+# This sets the ARCHFLAGS environment variable to your native architecture
+# On Windows:
+# gem install mysql
+# Choose the win32 build.
+# Install MySQL and put its /bin directory on your path.
+#
+# And be sure to use new-style password hashing:
+# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
+development:
+ adapter: mysql
+ encoding: utf8
+ database: <%= db_name %>_development
+ username: root
+ password:
+ socket: /tmp/mysql.sock
+
+# Warning: The database defined as 'test' will be erased and
+# re-generated from your development database when you run 'rake'.
+# Do not set this db to the same as development or production.
+test:
+ adapter: mysql
+ encoding: utf8
+ database: <%= db_name %>_test
+ username: root
+ password:
+ socket: /tmp/mysql.sock
+
+production:
+ adapter: mysql
+ encoding: utf8
+ database: <%= db_name %>
+ username: <%= db_user %>
+ password: <%= db_pass %>
+ socket: /var/lib/mysql/mysql.sock
View
26 generators/templates/ruby/ruby_install.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+set -e
+trap ERROR ERR
+
+cd /usr/src
+#wget -nv ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p110.tar.gz
+tar xzf ruby-1.8.6-p110.tar.gz
+cd ruby-1.8.6-p110
+echo "Configuring ruby..."
+./configure --prefix=/usr > configure.log
+echo "Compiling ruby..."
+make > make.log
+echo "Installing ruby..."
+make install > make_install.log
+
+# Fix openssl
+cd /usr/src/ruby-1.8.6-p110/ext/openssl
+echo "Fix for ruby openssl..."
+ruby extconf.rb > extconf.log
+make clean > make.log
+make >> make.log
+make install >> make.log
+
+cd /usr/src
+rm ruby-1.8.6-p110.tar.gz
View
13 generators/templates/ruby/rubygems_install.sh
@@ -0,0 +1,13 @@
+#! /bin/sh
+
+set -e
+trap ERROR ERR
+
+cd /tmp
+wget -nv http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
+tar zxpf rubygems-1.0.1.tgz
+cd rubygems-1.0.1
+echo "Installing rubygems..."
+ruby setup.rb > ruby_setup.log
+cd ..
+rm -rf rubygems*
View
22 generators/templates/sphinx/install.sh.erb
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+trap ERROR ERR
+
+cd /tmp
+
+wget -nv http://www.sphinxsearch.com/downloads/sphinx-0.9.7.tar.gz
+
+tar zxpf sphinx-0.9.7.tar.gz
+
+cd sphinx-0.9.7
+echo "Configuring sphinx..."
+./configure --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql --prefix=<%= sphinx_prefix %> > configure.log
+echo "Compiling sphinx..."
+make > make.log
+echo "Installing sphinx..."
+make install > make_install.log
+
+cd ..
+rm -rf sphinx-0.9.7*
+
View
496 generators/templates/sphinx/sphinx.conf.erb
@@ -0,0 +1,496 @@
+#
+# Sphinx configuration file sample
+#
+
+#############################################################################
+## data source definition
+#############################################################################
+
+source <%= application %>
+{
+ # data source type
+ # for now, known types are 'mysql', 'pgsql' and 'xmlpipe'
+ # MUST be defined
+ type = mysql
+
+ # whether to strip HTML
+ # values can be 0 (don't strip) or 1 (do strip)
+ # WARNING, only works with mysql source for now
+ # WARNING, should work ok for PERFECTLY formed XHTML for now
+ # WARNING, POSSIBLE TO BUG on malformed everday HTML
+ # optional, default is 0
+ strip_html = 0
+
+ # what HTML attributes to index if stripping HTML
+ # format is as follows:
+ #
+ # index_html_attrs = img=alt,title; a=title;
+ #
+ # optional, default is to not index anything
+ index_html_attrs =
+
+ #####################################################################
+
+ # some straightforward parameters for 'mysql' source type
+ sql_host = 127.0.0.1
+ sql_user = <%= db_user %>
+ sql_pass = <%= db_pass %>
+ sql_db = <%= db_name %>
+ sql_port = 3306 # optional, default is 3306
+
+ # sql_sock = /tmp/mysql.sock
+ #
+ # optional
+ # usually '/var/lib/mysql/mysql.sock' on Linux
+ # usually '/tmp/mysql.sock' on FreeBSD
+
+ # pre-query, executed before the main fetch query
+ # useful eg. to setup encoding or mark records
+ # optional, default is empty
+ #
+ # sql_query_pre = SET CHARACTER_SET_RESULTS=cp1251
+ sql_query_pre = SET NAMES UTF8
+
+ # main document fetch query
+ #
+ # you can specify up to 32 (formally SPH_MAX_FIELDS in sphinx.h) fields;
+ # all of the fields which are not document_id or attributes (see below)
+ # will be full-text indexed
+ #
+ # document_id MUST be the very first field
+ # document_id MUST be positive (non-zero, non-negative)
+ # document_id MUST fit into 32 bits
+ # document_id MUST be unique
+ #
+ # mandatory
+ sql_query = \
+ SELECT id, UNIX_TIMESTAMP(created_at) AS created_at, body FROM todo
+
+ # query range setup
+ #
+ # useful to avoid MyISAM table locks and big result sets
+ # when indexing lots of data
+ #
+ # to use query ranges, you should
+ # 1) provide a query to fetch min/max id (ie. id range) from data set;
+ # 2) configure step size in which this range will be walked;
+ # 3) use $start and $end macros somewhere in the main fetch query.
+ #
+ # 'sql_query_range' must return exactly two integer fields
+ # in exactly min_id, max_id order
+ #
+ # 'sql_range_step' must be a positive integer
+ # optional, default is 1024
+ #
+ # 'sql_query' must contain both '$start' and '$end' macros
+ # if you are using query ranges (because it obviously would be an
+ # error to index the whole table many times)
+ #
+ # note that the intervals specified by $start/$end do not
+ # overlap, so you should NOT remove document ids which are exactly
+ # equal to $start or $end in your query
+ #
+ # here's an example which will index 'documents' table
+ # fetching (at most) one thousand entries at a time:
+ #
+ # sql_query_range = SELECT MIN(id),MAX(id) FROM documents
+ # sql_range_step = 1000
+ # sql_query = \
+ # SELECT doc.id, doc.id AS group, doc.title, doc.data \
+ # FROM documents doc \
+ # WHERE id>=$start AND id<=$end
+
+
+ # attribute columns
+ #
+ # attribute values MUST be positive (non-zero, non-negative) integers
+ # attribute values MUST fit into 32 bits
+ #
+ # attributes are additional values associated with each document which
+ # may be used to perform additional filtering and sorting during search.
+ # attributes are NOT full-text indexed; they are stored in the full text
+ # index as is.
+ #
+ # a good example would be a forum posts table. one might need to search
+ # through 'title' and 'content' fields but to limit search to specific
+ # values of 'author_id', or 'forum_id', or to sort by 'post_date', or to
+ # group matches by 'thread_id', or to group posts by month of the
+ # 'post_date' and provide statistics.
+ #
+ # this all can be achieved by specifying all the mentioned columns
+ # (excluding 'title' and 'content' which are full-text fields) as
+ # attributes and then using API calls to setup filtering, sorting,
+ # and grouping.
+ #
+ # sql_group_column is used to declare integer attributes.
+ #
+ # sql_date_column is used to declare UNIX timestamp attributes.
+ #
+ # sql_str2ordinal_column is used to declare integer attributes which
+ # values are computed as ordinal numbers of corresponding column value
+ # in sorted list of column values. WARNING, all such strings values
+ # are going to be stored in RAM while indexing, and "C" locale will
+ # be used when sorting!
+ #
+ # starting with 0.9.7, there may be multiple attribute columns specified.
+ # here's an example for that mentioned posts table:
+ #
+ # sql_group_column = author_id
+ # sql_group_column = forum_id
+ # sql_group_column = thread_id
+ # sql_date_column = post_unix_timestamp
+ # sql_date_column = last_edit_unix_timestamp
+ #
+ # optional, default is empty
+ ##sql_group_column = group_id
+ sql_date_column = created_at
+ # sql_str2ordinal_column = author_name
+
+ # post-query, executed on the end of main fetch query
+ #
+ # note that indexing is NOT completed at the point when post-query
+ # gets executed and might very well fail
+ #
+ # optional, default is empty
+ ##sql_query_post =
+
+ # post-index-query, executed on succsefully completed indexing
+ #
+ # $maxid macro is the max document ID which was actually
+ # fetched from the database
+ #
+ # optional, default is empty
+ #
+ # sql_query_post_index = REPLACE INTO counters ( id, val ) \
+ # VALUES ( 'max_indexed_id', $maxid )
+
+
+ # document info query
+ #
+ # ONLY used by search utility to display document information
+ # MUST be able to fetch document info by its id, therefore
+ # MUST contain '$id' macro
+ #
+ # optional, default is empty
+ ##sql_query_info = SELECT * FROM documents WHERE id=$id
+
+ #####################################################################
+
+ # demo config for 'xmlpipe' source type is a little below
+ #
+ # with xmlpipe, indexer opens a pipe to a given command,
+ # and then reads documents from stdin
+ #
+ # indexer expects one or more documents from xmlpipe stdin
+ # each document must be formatted exactly as follows:
+ #
+ # <document>
+ # <id>123</id>
+ # <group>45</group>
+ # <timestamp>1132223498</timestamp>
+ # <title>test title</title>
+ # <body>
+ # this is my document body
+ # </body>
+ # </document>
+ #
+ # timestamp element is optional, its default value is 1
+ # all the other elements are mandatory
+
+ # type = xmlpipe
+ # xmlpipe_command = cat /var/test.xml
+}
+
+
+# inherited source example
+#
+# all the parameters are copied from the parent source,
+# and may then be overridden in this source definition
+##source src1stripped : src1
+##{
+## strip_html = 1
+##}
+
+#############################################################################
+## index definition
+#############################################################################
+
+# local index example
+#
+# this is an index which is stored locally in the filesystem
+#
+# all indexing-time options (such as morphology and charsets)
+# are configured per local index
+index <%= application %>
+{
+ # which document source to index
+ # at least one MUST be defined
+ #
+ # multiple sources MAY be specified; to do so, just add more
+ # "source = NAME" lines. in this case, ALL the document IDs
+ # in ALL the specified sources MUST be unique
+ source = <%= application %>
+
+ # this is path and index file name without extension
+ #
+ # indexer will append different extensions to this path to
+ # generate names for both permanent and temporary index files
+ #
+ # .tmp* files are temporary and can be safely removed
+ # if indexer fails to remove them automatically
+ #
+ # .sp* files are fulltext index data files. specifically,
+ # .spa contains attribute values attached to each document id
+ # .spd contains doclists and hitlists
+ # .sph contains index header (schema and other settings)
+ # .spi contains wordlists
+ #
+ # MUST be defined
+ path = /var/sphinx/<%= application %>
+
+ # docinfo (ie. per-document attribute values) storage strategy
+ # defines how docinfo will be stored
+ #
+ # available values are "none", "inline" and "extern"
+ #
+ # "none" means there'll be no docinfo at all (no groups/dates)
+ #
+ # "inline" means that the docinfo will be stored in the .spd
+ # file along with the document ID lists (doclists)
+ #
+ # "extern" means that the docinfo will be stored in the .spa
+ # file separately
+ #
+ # externally stored docinfo should (basically) be kept in RAM
+ # when querying; therefore, "inline" may be the only viable option
+ # for really huge (50-100+ million docs) datasets. however, for
+ # smaller datasets "extern" storage makes both indexing and
+ # searching MUCH more efficient.
+ #
+ # additional search-time memory requirements for extern storage are
+ #
+ # ( 1 + number_of_attrs )*number_of_docs*4 bytes
+ #
+ # so 10 million docs with 2 groups and 1 timestamp will take
+ # (1+2+1)*10M*4 = 160 MB of RAM. this is PER DAEMON, ie. searchd
+ # will alloc 160 MB on startup, read the data and keep it shared
+ # between queries; the children will NOT allocate additional
+ # copies of this data.
+ #
+ # default is "extern" (as most collections are smaller than 100M docs)
+ docinfo = extern
+
+ # morphology
+ #
+ # currently supported morphology preprocessors are Porter stemmers
+ # for English and Russian, and Soundex. more stemmers could be added
+ # at users request.
+ #
+ # available values are "none", "stem_en", "stem_ru", "stem_enru",
+ # and "soundex"
+ #
+ # optional, default is "none"
+ #
+ # morphology = none
+ # morphology = stem_en
+ # morphology = stem_ru
+ # morphology = stem_enru
+ # morphology = soundex
+ morphology = none
+
+ # stopwords file
+ #
+ # format is plain text in whatever encoding you use
+ # optional, default is empty
+ #
+ # stopwords = /var/data/stopwords.txt
+ #stopwords =
+
+ # minimum word length
+ #
+ # only the words that are of this length and above will be indexed;
+ # for example, if min_word_len is 4, "the" won't be indexed,
+ # but "they" will be.
+ #
+ # default is 1, which (obviously) means to index everything
+ min_word_len = 1
+
+ # charset encoding type
+ #
+ # known types are 'sbcs' (Single Byte CharSet) and 'utf-8'
+ #
+ # optional, default is sbcs
+ charset_type = utf-8
+
+ # charset definition and case folding rules "table"
+ #
+ # optional, default value depends on charset_type
+ #
+ # for now, defaults are configured to support English and Russian
+ # this behavior MAY change in future versions
+ #
+ # 'sbcs' default value is
+ # charset_table = 0..9, A..Z->a..z, _, a..z, U+A8->U+B8, U+B8, U+C0..U+DF->U+E0..U+FF, U+E0..U+FF
+ #
+ # 'utf-8' default value is
+ # charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
+
+ # minimum prefix length
+ #
+ # if prefix length is positive, indexer will not only index all words,
+ # but all the possible prefixes (ie. word beginnings) as well
+ #
+ # for instance, "exam" query against such index will match documents
+ # which contain "example" word, even if they do not contain "exam"
+ #
+ # indexing prefixes will make the index grow significantly
+ # and could degrade search times
+ #
+ # currently there's no way to rank perfect word matches higher
+ # than prefix matches using only one index; you could setup two
+ # indexes for that
+ #
+ # default is 0, which means NOT to index prefixes
+ min_prefix_len = 0
+
+ # minimum infix length
+ #
+ # if infix length is positive, indexer will not only index all words,
+ # but all the possible infixes (ie. characters subsequences starting
+ # anywhere inside the word) as well
+ #
+ # for instance, "amp" query against such index will match documents
+ # which contain "example" word, even if they do not contain "amp"
+ #
+ # indexing prefixes will make the index grow significantly
+ # and could degrade search times
+ #
+ # currently there's no way to rank perfect word matches higher
+ # than infix matches using only one index; you could setup two
+ # indexes for that
+ #
+ # default is 0, which means NOT to index infixes
+ min_infix_len = 0
+
+ # n-grams length
+ #
+ # n-grams provide basic CJK support for unsegmented texts. if using
+ # n-grams, streams of CJK characters are indexed as n-grams. for example,
+ # if incoming stream is ABCDEF and n is 2, this text would be indexed
+ # as if it was AB BC CD DE EF.
+ #
+ # this feature is in alpha version state and only n=1 is currently
+ # supported; this is going to be improved.
+ #
+ # note that if search query is segmented (ie. words are separated with
+ # whitespace), words are in quotes and extended matching mode is used,
+ # then all matching documents will be returned even if their text was
+ # *not* segmented. in the example above, ABCDEF text will be indexed as
+ # A B C D E F, and "BCD" query will be transformed to "B C D" (where
+ # quotes is phrase matching operator), so the document will match.
+ #
+ # optional, default is 0, which means NOT to use n-grams
+ #
+ # ngram_len = 1
+
+ # n-gram characters table
+ #
+ # specifies what specific characters are subject to n-gram
+ # extraction. format is similar to charset_table.
+ #
+ # optional, default is empty
+ #
+ # ngrams_chars = U+3000..U+2FA1F
+}
+
+
+# inherited index example
+#
+# all the parameters are copied from the parent index,
+# and may then be overridden in this index definition
+##index test1stemmed : test1
+##{
+## path = /var/data/test1stemmed
+## morphology = stem_en
+##}
+
+
+#############################################################################
+## indexer settings
+#############################################################################
+
+indexer
+{
+ # memory limit
+ #
+ # may be specified in bytes (no postfix), kilobytes (mem_limit=1000K)
+ # or megabytes (mem_limit=10M)
+ #
+ # will grow if set unacceptably low
+ # will warn if set too low and potentially hurting the performance
+ #
+ # optional, default is 32M
+ mem_limit = 32M
+}
+
+#############################################################################
+## searchd settings
+#############################################################################
+
+searchd
+{
+ # IP address on which search daemon will bind and accept
+ # incoming network requests
+ #
+ # optional, default is to listen on all addresses,
+ # ie. address = 0.0.0.0
+ #
+ address = 127.0.0.1
+ # address = 192.168.0.1
+
+
+ # port on which search daemon will listen
+ port = 3312
+
+
+ # log file
+ # searchd run info is logged here
+ log = /var/sphinx/searchd.log
+
+
+ # query log file
+ # all the search queries are logged here
+ query_log = /var/sphinx/query.log
+
+
+ # client read timeout, seconds
+ read_timeout = 5
+
+
+ # maximum amount of children to fork
+ # useful to control server load
+ max_children = 30
+
+
+ # a file which will contain searchd process ID
+ # used for different external automation scripts
+ # MUST be present
+ pid_file = /var/sphinx/searchd.pid
+
+
+ # maximum amount of matches this daemon would ever retrieve
+ # from each index and serve to client
+ #
+ # this parameter affects per-client memory and CPU usage
+ # (16+ bytes per match) in match sorting phase; so blindly raising
+ # it to 1 million is definitely NOT recommended
+ #
+ # starting from 0.9.7, it can be decreased on the fly through
+ # the corresponding API call; increasing is prohibited to protect
+ # against malicious and/or malformed requests
+ #
+ # default is 1000 (just like with Google)
+ max_matches = 1000
+}
+
+# --eof--
View
4 generators/templates/sphinx/sphinx.monitrc.erb
@@ -0,0 +1,4 @@
+check process sphinx_<%= application %> with pidfile <%= sphinx_pid_path %>
+ group search
+ start program = "/sbin/service sphinx_<%= application %> start"
+ stop program = "/sbin/service sphinx_<%= application %> stop"
View
67 generators/templates/sphinx/sphinx_app.initd.centos.erb
@@ -0,0 +1,67 @@
+#! /bin/sh
+# sphinx: Sphinx search daemon for <%= application %>
+#
+# chkconfig: - 86 14
+# description: sphinx search daemon
+# processname: searchd
+#
+# Author: Gabriel Handford http://ducktyper.com
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+RETVAL=0
+
+DESC="sphinx daemon (<%= application %>)"
+NAME=searchd
+DAEMON=<%= sphinx_bin_path %>/searchd
+CONFIGFILE=<%= sphinx_conf_path %>
+PIDFILE=<%= sphinx_pid_path %>
+
+start() {
+ daemon --user <%= user %> $DAEMON --config $CONFIGFILE
+ RETVAL=$?
+ echo
+ return $RETVAL;
+}
+
+stop() {
+ kill -QUIT `cat $PIDFILE` || echo -n " not running"
+}
+
+reload() {
+ kill -HUP `cat $PIDFILE` || echo -n " can't reload"
+}
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: $NAME"
+ start
+ RETVAL=$?;
+ ;;
+ stop)
+ echo -n "Stopping $DESC: $NAME"
+ stop
+ RETVAL=$?;
+ ;;
+ reload)
+ echo -n "Reloading $DESC configuration..."
+ reload
+ RETVAL=$?;
+ echo "reloaded."
+ ;;
+ restart)
+ echo -n "Restarting $DESC: $NAME"
+ stop
+ # Sleep after stop
+ sleep 1
+ start
+ RETVAL=$?;
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|force-reload}" >&2
+ RETVAL=3;
+ ;;
+esac
+
+exit $RETVAL;
View
57 generators/templates/sphinx/sphinx_app.initd.erb
@@ -0,0 +1,57 @@
+#! /bin/sh
+# sphinx Startup script for sphinx
+#
+# chkconfig: - 86 14
+# description: sphinx search daemon
+#
+# Author: Gabriel Handford http://ducktyper.com
+
+set -e
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DESC="sphinx daemon"
+NAME=searchd
+DAEMON=<%= sphinx_bin_path %>/searchd
+CONFIGFILE=<%= sphinx_conf_path %>
+PIDFILE=<%= sphinx_pid_path %>
+
+start() {
+ $DAEMON --config $CONFIGFILE || echo -n " already running"
+}
+
+stop() {
+ kill -QUIT `cat $PIDFILE` || echo -n " not running"
+}
+
+reload() {
+ kill -HUP `cat $PIDFILE` || echo -n " can't reload"
+}
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: $NAME"
+ start
+ ;;
+ stop)
+ echo -n "Stopping $DESC: $NAME"
+ stop
+ ;;
+ reload)
+ echo -n "Reloading $DESC configuration..."
+ reload
+ echo "reloaded."
+ ;;
+ restart)
+ echo -n "Restarting $DESC: $NAME"
+ stop
+ # Sleep
+ sleep 1
+ start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}" >&2
+ exit 3
+ ;;
+esac
+
+exit 0
View
1  init.rb
@@ -20,4 +20,3 @@ module Configr::Packagers; end
require "configr/helper"
require "configr/config"
-require "configr/tasks"
View
9 recipes/aspell.rb
@@ -1,9 +0,0 @@
-namespace :aspell do
-
- task :install do
-
- package_install([ "aspell", "aspell-devel", "aspell-en", "aspell-es" ])
-
- end
-
-end
View
8 recipes/gems.rb
@@ -1,15 +1,7 @@
namespace :gems do
- desc "Install gems from profile"
- task :install_manual do
- profile = choose_profile
- gems = profile["gems"]
- gem_install(gems) if gems
- end
-
desc "Install gems"
task :install do
- gems = fetch(:gems)
gem_install(gems) if gems
end
View
6 recipes/imagemagick.rb
@@ -1,10 +1,8 @@
namespace :imagemagick do
task :install do
-
- package_install([ "libjpeg-devel", "libpng-devel", "glib2-devel", "fontconfig-devel", "zlib-devel",
- "libwmf-devel", "freetype-devel", "libtiff-devel"])
-
+ # Dependencies: "libjpeg-devel", "libpng-devel", "glib2-devel", "fontconfig-devel", "zlib-devel",
+ # "libwmf-devel", "freetype-devel", "libtiff-devel"
script_install("imagemagick/install.sh")
end
View
17 recipes/install.rb
@@ -1,19 +1,8 @@
namespace :install do
- set :profile, nil
-
task :default do
- # TODO: This sucks (mostly capistrano's fault)
- profile = fetch(:profile)
- profile = choose_profile unless profile
- set :profile, profile
- set :gems, profile["gems"]
-
- packager_type = profile["packager"]["type"]
- packages_to_remove = profile["packager"]["remove"]
- packages_to_add = profile["packager"]["install"]
- tasks = profile["tasks"]
- namespace = profile["namespace"]
+ # Choose profile, and load capistrano settings
+ fetch(:profile)
# Setup packager
setup_packager(packager_type)
@@ -28,7 +17,7 @@
package_install(packages_to_add)
# These run after install task and install all the apps
- tasks.each do |task_name|
+ install_tasks.each do |task_name|
after "install", task_name
end
end
View
22 recipes/memcached.rb
@@ -1,29 +1,15 @@
namespace :memcached do
- after "memcached:install", "memcached:install_init"
- after "memcached:install", "memcached:install_monit"
-
- set :memcached_pid_path, "/var/run/memcached.pid"
- set :memcached_port, 11211
-
desc "Install memcached"
task :install do
+ put load_template("memcached/memcached.initd.centos.erb", binding), "/tmp/memcached.initd"
script_install("memcached/install.sh")
end
-
- desc "Install memcached init"
- task :install_init do
- put load_template("memcached/memcached.initd.centos.erb", binding), "/tmp/memcached.initd"
- sudo "install -o root /tmp/memcached.initd /etc/init.d/memcached && rm -f /tmp/memcached.initd"
-
- sudo "/sbin/chkconfig --level 345 memcached on"
- end
-
+ desc "Install memcached monit hooks"
task :install_monit do
- put load_template("memcached/memcached.monitrc.erb", binding), "/tmp/memcached.monitrc"
-
- sudo "install -o root /tmp/memcached.monitrc /etc/monit/memcached.monitrc && rm -f /tmp/memcached.monitrc"
+ put load_template("memcached/memcached.monitrc.erb", binding), "/tmp/memcached.monitrc"
+ script_install("memcached/install_monit.sh")
end
end
View
7 recipes/mongrel_cluster.rb
@@ -2,12 +2,7 @@
namespace :mongrel_cluster do
after "mongrel_cluster:setup", "mongrel_cluster:setup_monit"
-
- desc "Install mongrel and mongrel_cluster"
- task :install do
- sudo "gem install mongrel mongrel_cluster"
- end
-
+
desc "Create mongrel cluster"
task :setup do
run "mkdir -p #{shared_path}/config"
View
42 recipes/monit.rb
@@ -1,48 +1,16 @@
namespace :monit do
- after "monit:install", "monit:install_rc"
- after "monit:install", "monit:install_init"
- after "monit:install", "monit:install_cert"
-
desc "Install monit"
task :install do
- package_install([ "flex", "byacc" ])
- script_install("monit/install.sh")
- end
-
- desc "Install monit RC"
- task :install_rc do
- sudo "mkdir -p /etc/monit"
-
- set :monit_port, Proc.new { Capistrano::CLI.ui.ask('Monit port: ') }
- set :monit_password, Proc.new { Capistrano::CLI.ui.ask('Monit admin password (to set): ') }
-
- put load_template("monit/monitrc.erb", binding), "/tmp/monitrc"
-
- sudo "install -o root -m 700 /tmp/monitrc /etc/monitrc && rm -f /tmp/monitrc"
- end
-
- desc "Install init.d"
- task :install_init do
+ # Dependencies: "flex", "byacc"
put load_template("monit/monit.initd.centos.erb", binding), "/tmp/monit.initd"
-
- sudo "install -o root /tmp/monit.initd /etc/init.d/monit && rm -f /tmp/monit.initd"
-
- # Started from inittab
- #sudo "/sbin/chkconfig --level 345 monit on"
+ put load_template("monit/monitrc.erb", binding), "/tmp/monitrc"
+ put load_file("monit/monit.cnf"), "/tmp/monit.cnf"
+ script_install("monit/install.sh")
script_install("monit/patch_inittab.sh")
- end
-
-
- desc "Install monit cert"
- task :install_cert do
- sudo "mkdir -p /var/certs"
-
- put load_file("monit/monit.cnf"), "/var/certs/monit.cnf"
-
script_install("monit/cert.sh")
end
-
+
end
View
25 recipes/mysql.rb
@@ -1,38 +1,23 @@
# Mysql recipes
namespace :mysql do
- after "mysql:install", "mysql:install_monit"
-
desc "Install mysql"
task :install do
-
- set :mysql_admin_password, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password (to set): ') }
-
- package_install([ "mysql", "mysql-devel", "mysql-server" ])
script_install("mysql/install.sh.erb")
end
- desc "Create monit configuration for mysql"
+ desc "Install mysql monit hooks"
task :install_monit do
-
- pid_path = "/var/run/mysqld/mysqld.pid"
- set :db_port, Proc.new { Capistrano::CLI.ui.ask('Mysql port: ') }
-
- put load_template("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"
-
- sudo "install -o root /tmp/mysql.monitrc /etc/monit/mysql.monitrc && rm -f /tmp/mysql.monitrc"
+ put load_template("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"
+ script_install("mysql/install_monit.sh")
end
desc "Create database user, and database with appropriate permissions"
- task :setup do
-
- set :mysql_admin_password, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password: ') }
-
- # Locations can access from
+ task :setup do
+ # Add localhost to grant locations
locations_for_grant = [ "localhost", web_host ]
put load_template("mysql/install_db.sql.erb", binding), "/tmp/install_db_#{application}.sql"
-
run "mysql -u root -p#{mysql_admin_password} < /tmp/install_db_#{application}.sql"
end
View
22 recipes/nginx.rb
@@ -1,33 +1,23 @@
# Nginx recipes
namespace :nginx do
- after "nginx:install", "nginx:install_monit"
-
- # Conf variables
- set :nginx_bin_path, "/sbin/nginx"
- set :nginx_conf_path, "/etc/nginx/nginx.conf"
- set :nginx_pid_path, "/var/run/nginx.pid"
- set :nginx_prefix_path, "/var/nginx"
-
# Callbacks
after "nginx:setup", "nginx:restart"
desc "Install nginx, conf, initscript, nginx user and service"
task :install do
- package_install([ "pcre-devel", "openssl", "openssl-devel" ])
+ # Dependencies: "pcre-devel", "openssl", "openssl-devel"
- run("rm -rf /tmp/nginx && mkdir -p /tmp/nginx")
-
- put(load_template("nginx/nginx.initd.erb", binding), "/tmp/nginx/nginx.initd")
- put(load_template("nginx/nginx.conf.erb", binding), "/tmp/nginx/nginx.conf")
+ put(load_template("nginx/nginx.initd.erb", binding), "/tmp/nginx.initd")
+ put(load_template("nginx/nginx.conf.erb", binding), "/tmp/nginx.conf")
- script_install("nginx/install.sh.erb")
+ script_install("nginx/install.sh.erb")
end
- desc "Create monit configuration for nginx"
+ desc "Install nginx monit hooks"
task :install_monit do
put load_template("nginx/nginx.monitrc.erb", binding), "/tmp/nginx.monitrc"
- sudo "mkdir -p /etc/monit && install -o root /tmp/nginx.monitrc /etc/monit/nginx.monitrc && rm -f /tmp/nginx.monitrc"
+ script_install("nginx/install_monit.sh")
end
View
32 recipes/profiles/centos-sick.yml
@@ -1,32 +0,0 @@
-namespace: "centos"
-description: "Install based on thoughtpolice centos 5.1 image"
-packager:
- type: "yum"
- remove:
- - "openoffice.org-*"
- - "ImageMagick"
- install:
- - "gcc"
- - "kernel-devel"
- - "libevent-devel"
- - "libxml2-devel"
- - "openssl"
- - "openssl-devel"
-tasks:
- - "centos:setup"
- - "ruby:install"
- - "nginx:install"
- - "mongrel_cluster:install"
- - "mysql:install"
- - "sphinx:install"
- - "monit:install"
- - "aspell:install"
- - "imagemagick:install"
- - "memcached:install"
- - "gems:install"
- - "centos:cleanup"
-gems:
- - "rake"
- - "mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --with-mysql-config"
- - "raspell"
- - "rmagick"
View
15 recipes/profiles/centos-test.yml
@@ -1,15 +0,0 @@
-namespace: "centos"
-description: "Test profile"
-packager:
- type: "yum"
- remove:
- - "openoffice.org-*"
- install:
- - "gcc"
- - "kernel-devel"
- - "libevent-devel"
- - "libxml2-devel"
-tasks:
- - "centos:cleanup"
-gems:
- - "rake"
View
5 recipes/ruby.rb
@@ -1,9 +1,8 @@
namespace :ruby do
- desc "Install ruby, rubygems and rake"
+ desc "Install ruby and rubygems"
task :install do
-
- package_install([ "ruby", "ruby-devel", "ruby-libs", "ruby-irb", "ruby-rdoc", "ruby-ri", "zlib", "zlib-devel" ])
+ # Dependencies: zlib, zlib-devel
# Install ruby 1.8.6
script_install("ruby/ruby_install.sh")
View
20 recipes/sphinx.rb
@@ -3,19 +3,15 @@
after "sphinx:setup", "sphinx:setup_monit"
- set :sphinx_prefix, "/usr/local/sphinx"
-
desc "Install sphinx"
task :install do
- package_install([ "gcc-c++" ])
+ # Dependencies: gcc-c++
script_install("sphinx/install.sh.erb")
end
desc "Setup sphinx for application"
task :setup do
- sphinx_prefix = fetch(:sphinx_prefix)
- application = config.application
sphinx_bin_path = "#{sphinx_prefix}/bin"
sphinx_conf_path = "#{shared_path}/config/sphinx.conf"
sphinx_pid_path = "#{shared_path}/pids/searchd.pid"
@@ -44,35 +40,23 @@
index_root = "#{shared_path}/var/index";
log_root = "#{shared_path}/log"
pid_root = "#{shared_path}/pids"
- sphinx_host = config.sphinx_host
- sphinx_port = config.sphinx_port
- db_name = config.db_name
- db_user = config.db_user
- db_pass = config.db_pass
- db_host = config.db_host
- db_port = config.db_port
put load_project_template("config/templates/sphinx.conf.erb", binding), "#{shared_path}/config/sphinx.conf"
-
- # Dont symlink in since we dont want to use sphinx rake tasks in deployed environment
- #run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/sphinx.conf"
end
desc "Rotate sphinx index for application"
task :rotate_all do
- sphinx_prefix = fetch(:sphinx_prefix)
run "#{sphinx_prefix}/bin/indexer --config #{shared_path}/config/sphinx.conf --rotate --all"
end
desc "Build sphinx indexes for application"
task :index_all do
- sphinx_prefix = fetch(:sphinx_prefix)
run "#{sphinx_prefix}/bin/indexer --config #{shared_path}/config/sphinx.conf --all"
end
desc "Start sphinx"
task :start do
# TODO: Monit
- sudo "/sbin/service sphinx_#{application} start"
+ sudo "/sbin/service monit restart sphinx_#{application}"
end
end
View
32 tasks/configr.rake
@@ -1,32 +0,0 @@
-require File.dirname(__FILE__) + "/../init"
-
-# Tasks for configr.
-# Otherwise use capistrano.
-namespace :configr do
-
- # Create Capfile and deploy.rb
- task :setup do
- include Configr::Tasks
- task_setup
- end
-
- # Remove capistrano files
- task :clean do
- include Configr::Tasks
- task_clean
- end
-
- # Create configr yaml config
- task :bootstrap do
- include Configr::Tasks
- task_bootstrap
- end
-
- # Update config and re-run setup
- task :update do
- include Configr::Tasks
- task_update
- task_setup
- end
-
-end
View
10 test/test_helper.rb
@@ -1,10 +1,2 @@
require 'test/unit'
-require 'rubygems'
-require 'active_support'
-
-$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
-
-RAILS_ROOT = '.' unless defined?(RAILS_ROOT)
-
-require 'rake'
-Dir[File.dirname(__FILE__) + "/../tasks/*.rake"].each { |task| load task }
+require File.dirname(__FILE__) + '/../lib/capigen'
Please sign in to comment.
Something went wrong with that request. Please try again.