Permalink
Browse files

Merge branch 'nginx-module' of git://Homeslice.local into nginx-module

Conflicts:
	config/install.rb
	config/stack/nginx.rb
  • Loading branch information...
2 parents 604f1ec + 6de5237 commit 7bf6664c0694231a0b3f5190e6f333c845bdabf3 @benschwarz committed May 14, 2009
View
@@ -1,22 +1,29 @@
-# Require our stack
-%w(essential apache scm ruby_enterprise memcached postgresql mysql).each do |r|
- require File.join(File.dirname(__FILE__), 'stack', r)
-end
+$:<< File.join(File.dirname(__FILE__), 'stack')
+
+# ===============
+# = Web servers =
+# ===============
+
+# Apache and Nginx are interchangable simply by choosing which file should be included to the stack
+
+# Apache has some extra installers for etags, gzip/deflate compression and expires headers.
+# These are enabled by default when you choose Apache, you can remove these dependencies within
+# stack/apache.rb
+
+# require 'apache'
+require 'nginx'
+
+# Require the rest of our stack
+%w(essential scm ruby_enterprise memcached postgresql mysql).each(&method(:require))
# What we're installing to your server
# Take what you want, leave what you don't
# Build up your own and strip down your server until you get it right.
-policy :passenger_stack, :roles => :app do
+policy :stack, :roles => :app do
requires :webserver # Apache or Nginx
-
- requires :apache_etag_support # == Apache extras
- requires :apache_deflate_support # Read about these specialties in
- requires :apache_expires_support # stack/apache.rb
-
- requires :passenger # Passenger
+ requires :appserver # Passenger
requires :ruby_enterprise # Ruby Enterprise edition
- requires :database # MySQL or Postgres
- requires :ruby_database_driver # mysql or postgres gems
+ requires :database # MySQL or Postgres, also installs rubygems for each
requires :scm # Git
requires :memcached # Memcached
requires :libmemcached # Libmemcached
@@ -42,8 +49,8 @@
# Depend on a specific version of sprinkle
begin
- gem 'sprinkle', ">= 0.2.1"
+ gem 'sprinkle', ">= 0.2.3"
rescue Gem::LoadError
- puts "sprinkle 0.2.1 required.\n Run: `sudo gem install sprinkle`"
+ puts "sprinkle 0.2.3 required.\n Run: `sudo gem install sprinkle`"
exit
end
View
@@ -5,10 +5,11 @@
end
verify do
- has_process 'apache2'
+ has_executable '/usr/sbin/apache2'
end
requires :build_essential
+ recommends :apache_etag_support, :apache_deflate_support, :apache_expires_support
end
package :apache2_prefork_dev do
@@ -18,8 +19,8 @@
package :passenger, :provides => :appserver do
description 'Phusion Passenger (mod_rails)'
- version '2.1.3'
- gem 'passenger' do
+ version '2.2.1'
+ gem 'passenger', :version => version do
post :install, 'echo -en "\n\n\n\n" | sudo passenger-install-apache2-module'
# Create the passenger conf file
@@ -45,6 +46,7 @@
end
requires :apache, :apache2_prefork_dev, :ruby_enterprise
+ recommends :passenger_binaries
end
# These "installers" are strictly optional, I believe
@@ -60,7 +62,6 @@
push_text config, apache_conf, :sudo => true
verify { file_contains apache_conf, "Passenger-stack-etags"}
- requires :apache
end
# mod_deflate, compress scripts before serving.
@@ -80,7 +81,6 @@
push_text config, apache_conf, :sudo => true
verify { file_contains apache_conf, "Passenger-stack-deflate"}
- requires :apache
end
# mod_expires, add long expiry headers to css, js and image files
@@ -99,5 +99,4 @@
push_text config, apache_conf, :sudo => true
verify { file_contains apache_conf, "Passenger-stack-expires"}
- requires :apache
end
View
@@ -5,6 +5,8 @@
verify do
has_executable 'mysql'
end
+
+ recommends :mysql_driver
end
package :mysql_driver, :provides => :ruby_database_driver do
@@ -15,5 +17,5 @@
has_gem 'mysql'
end
- requires :mysql, :ruby_enterprise
+ requires :ruby_enterprise
end
View
@@ -1,9 +1,40 @@
+# =========
+# = Notes =
+# =========
+
+# The phusion guys have made it so that you can install nginx and passenger in one
+# fell swoop, it is for this reason and cleanliness that I haven't decided to install
+# nginx and passenger separately, otherwise nginx ends up being dependent on passenger
+# so that it can call --add-module within its configure statement - That in itself would
+# be strange.
+
package :nginx, :provides => :webserver do
- description "Nginx, red like communism"
+ puts "Nginx installed by passenger"
+end
+
+package :passenger, :provides => :appserver do
+ description 'Phusion Passenger (mod_rails)'
+ version '2.2.3'
- verify do
- has_binary "/usr/local/nginx"
+ gem 'passenger', :version => version do
+ # Install nginx and the module
+ post :install, "sudo passenger-install-nginx-module --auto --auto-download --prefix=/usr/local/nginx"
+
+ post :install do
+ # Install nginx init.d script
+ #push_text File.read(File.join(File.dirname(__FILE__), 'nginx', 'init.d')), "/etc/init.d/nginx", :sudo => true
+ end
+
+ #post :install, "sudo chmod +x /etc/init.d/nginx"
+ #post :install, "sudo /usr/sbin/update-rc.d -f nginx defaults"
+ #post :install, "sudo /etc/init.d/nginx start"
end
- requires :build_essential
+ requires :ruby_enterprise
+ recommends :passenger_binaries
+
+ #verify do
+ # has_executable "/usr/local/nginx/sbin/nginx"
+ # has_gem "passenger", version
+ #end
end
View
@@ -0,0 +1,63 @@
+#! /bin/sh
+
+### BEGIN INIT INFO
+# Provides: nginx
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: starts the nginx web server
+# Description: starts nginx using start-stop-daemon
+### END INIT INFO
+
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/local/nginx/sbin/nginx
+NAME=nginx
+DESC=nginx
+
+test -x $DAEMON || echo -n "$DESC daemon not found at $DAEMON" exit 0
+
+# Include nginx defaults if available
+if [ -f /etc/default/nginx ] ; then
+ . /etc/default/nginx
+fi
+
+set -e
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: "
+ start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
+ --exec $DAEMON -- $DAEMON_OPTS
+ echo "$NAME."
+ ;;
+ stop)
+ echo -n "Stopping $DESC: "
+ start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
+ --exec $DAEMON
+ echo "$NAME."
+ ;;
+ restart|force-reload)
+ echo -n "Restarting $DESC: "
+ start-stop-daemon --stop --quiet --pidfile \
+ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON
+ sleep 1
+ start-stop-daemon --start --quiet --pidfile \
+ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
+ echo "$NAME."
+ ;;
+ reload)
+ echo -n "Reloading $DESC configuration: "
+ start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
+ --exec $DAEMON
+ echo "$NAME."
+ ;;
+ *)
+ N=/etc/init.d/$NAME
+ echo "Usage: $N {start|stop|restart|force-reload}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
@@ -5,6 +5,8 @@
verify do
has_executable 'psql'
end
+
+ recommends :postgresql_driver
end
package :postgresql_driver, :provides => :ruby_database_driver do
@@ -15,5 +17,5 @@
has_gem 'postgres'
end
- requires :postgres, :ruby_enterprise
+ requires :ruby_enterprise
end
@@ -1,10 +1,10 @@
package :ruby_enterprise do
description 'Ruby Enterprise Edition'
- version '1.8.6-20090201'
+ version '1.8.6-20090421'
install_path = "/usr/local/ruby-enterprise"
- binaries = %w(erb gem irb passenger-config passenger-install-apache2-module passenger-make-enterprisey passenger-memory-stats passenger-spawn-server passenger-status passenger-stress-test rackup rails rake rdoc ree-version ri ruby testrb)
- source "http://rubyforge.org/frs/download.php/51100/ruby-enterprise-#{version}.tar.gz" do
+ binaries = %w(erb gem irb rackup rails rake rdoc ree-version ri ruby testrb)
+ source "http://rubyforge.org/frs/download.php/55511/ruby-enterprise-#{version}.tar.gz" do
custom_install 'sudo ./installer --auto=/usr/local/ruby-enterprise'
binaries.each {|bin| post :install, "ln -s #{install_path}/bin/#{bin} /usr/local/bin/#{bin}" }
@@ -21,4 +21,16 @@
package :ree_dependencies do
apt %w(zlib1g-dev libreadline5-dev libssl-dev)
-end
+ # requires :build_essential
+end
+
+package :passenger_binaries do
+ description "Symlinks passenger binaries"
+ binaries = %w(passenger-config passenger-install-nginx-module passenger-install-apache2-module passenger-make-enterprisey passenger-memory-stats passenger-spawn-server passenger-status passenger-stress-test)
+ install_path = "/usr/local/ruby-enterprise"
+ binaries.each {|bin| post :install, "ln -s #{install_path}/bin/#{bin} /usr/local/bin/#{bin}" }
+
+ verify do
+ binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{install_path}/bin/#{bin}" }
+ end
+end

0 comments on commit 7bf6664

Please sign in to comment.