Ticket #16 (closed defect: fixed)

Opened 2 years ago

Last modified 10 months ago

[PATCH] nginx and postgresql recipes and templates

Reported by: t.lucas@toolmantim.com Assigned to: mbailey
Priority: major Milestone:
Component: component1 Version:
Keywords: Cc:

Description

Attached is a patch that adds nginx and postgresql recipes. I haven't had a chance to test em within deprec yet (before doing the diff I made a few quick changes, mostly just changing the puts to render_template_to_file) , but worked fine in my own app. I haven't made any changes to the rest of deprec, as I'm not sure how you want to integrate them...

I integrated it the following way, but it may want to be rethought so you could do set :db, :postgresql and set :webserver, :nginx and have it automatically use the right one, or maybe you want to have the deprec config generator prompt the user to what DB and what webserver they want, and generate the relevant config stub for them.

require 'deprec/recipes'
require 'deprec/recipes/cache_svn'
require File.dirname(__FILE__) + '/recipes/nginx'
require File.dirname(__FILE__) + '/recipes/postgresql'

set :user, 'admin'
set :group, 'admin'
set :domain, "domain.com"
set :domain_aliases, %w(www.domain.com)

role :web, domain
role :app, domain
role :db,  domain, :primary => true

set :application, "someapp"
set :deploy_to, "/var/www/apps/#{application}"
set :repository_cache, "#{shared_path}/svn_trunk/"

set :repository, "https://mysvn/#{application}/trunk"

set :rails_env, "production"

# =============================================================================
# MONGREL OPTIONS
# =============================================================================
# set :mongrel_servers, 2
# set :mongrel_port, 8000
# set :mongrel_address, "127.0.0.1"
# set :mongrel_environment, "production"
set :mongrel_user, user
set :mongrel_group, group

# =============================================================================
# NGINX OPTIONS
# =============================================================================
set :nginx_server_name, domain
set :nginx_proxy_port, mongrel_port
set :nginx_proxy_address, mongrel_address
set :nginx_proxy_servers, mongrel_servers
set :nginx_doc_root, current_path + "/public"
set :nginx_server_aliases, [domain] + domain_aliases
set :nginx_user, user
set :nginx_group, group

set :nginx_setup_optional_modules, %w(http_flv_module)

# HACK to remove mysql-server from the list of installed apt packages
rails_ubuntu[:base].delete "mysql-server"
rails_ubuntu[:base].delete "libmysql-ruby"

# HACK I think this should be referred to as domain_aliases when we have multiple web servers?
set :apache_server_aliases, domain_aliases

desc "Overrides deprec to install nginx instead"
task :install_rails_stack do
  setup_user_perms
  enable_universe # we'll need some packages from the 'universe' repository
  disable_cdrom_install # we don't want to have to insert cdrom
  install_packages_for_rails # install packages that come with distribution
  install_rubygems
  install_gems
  install_nginx
end

desc "Overrides deprec to set up nginx instead of apache (relies on mongrel vars being set)"
task :setup_web, :roles => :web  do
  configure_nginx
end

desc "Overrides deprec to remove some apache variables (relies on mongrel vars being set)"
task :setup_app, :roles => :app  do
  install_mongrel_start_script
  setup_mongrel_cluster_path
  configure_mongrel_cluster
end

desc "Overrides deprec to set up postgresql instead of mysql"
task :setup_db, :roles => :db, :only => { :primary => true } do
  setup_postgresql
  gem.install "postgres -- --with-pgsql-lib-dir=/usr/lib/postgresql --with-pgsql-include-dir=/usr/include/postgresql"
end

Attachments

nginx_and_postgresql_recipes_and_templates.patch (16.0 kB) - added by t.lucas@toolmantim.com on 01/22/07 21:16:23.

Change History

01/22/07 21:16:23 changed by t.lucas@toolmantim.com

  • attachment nginx_and_postgresql_recipes_and_templates.patch added.

01/22/07 21:16:43 changed by t.lucas@toolmantim.com

  • summary changed from nginx and postgresql recipes and templates to [PATCH] nginx and postgresql recipes and templates.

01/25/07 04:53:54 changed by brendanschwartz # gmail

Really nice patch, worked like a charm. I had to add a line in the install recipe to make the init.d script executable (without it the start_nginx task won't work).

[snip]
    # Intall the daemon script
    deprec.render_template_to_file "nginx.init.d", nginx_ctl
    sudo "chmod +x #{nginx_ctl}"  #### << this is the addition
    send(run_method, "update-rc.d nginx defaults")
[snip]

Thanks, Brendan

01/25/07 05:22:07 changed by brendanschwartz # gmail

Another slight tweak: pass the :nginx_conf parameter to ./configure using the --conf-path switch. This way if people want their nginx.conf in /etc/nginx rather than the default, it will make the directory for them and set everything up.

    set :src_package, {
      :file => filebase + '.tar.gz',    
      :dir => filebase,  
      :url => "http://sysoev.ru/nginx/#{filebase}.tar.gz",
      :unpack => "tar zxf #{filebase}.tar.gz;",
      :configure => "./configure --sbin-path=/usr/local/sbin --conf-path=#{nginx_conf} --with-http_ssl_module #{nginx_setup_optional_modules.map { |m| "--with-#{m}" }.join(" ")};",  ### << this line changed
      :make => 'make;',
      :install => 'make install;',
      :post_install => 'chmod +x /usr/local/sbin/nginx'
    }

01/25/07 05:48:13 changed by brendanschwartz # gmail

Of course if we change the conf path we'll also need to adjust the nginx.conf template:

  # pull in mime-types. You can break out your config 
  # into as many include's as you want to make it cleaner
  include <%= File.dirname(nginx_conf) %>/mime.types;

If I have more changes, I'll create a patch. Promise.

01/28/07 01:54:27 changed by mbailey

  • owner changed from somebody to mbailey.

Hey guys, I've been busy and won't get a chance to look at this for another week or so. I like the idea of deprec supporting different setups like this. I'll get in touch with you for the latest patch. thanks for your patience!

05/05/07 02:34:11 changed by mbailey

  • status changed from new to closed.
  • resolution set to wontfix.

I'm tidying up old tickets. Please get in touch with me about adding this stuff to deprec-2.0 which will work with Cap2.0

06/14/07 04:53:37 changed by anonymous

  • status changed from closed to reopened.
  • resolution deleted.

Oh... no postgresql support in new future?..

07/10/07 14:11:29 changed by tredinertok

Hello Very interesting information! Thanks! Bye

08/03/07 18:27:33 changed by anonymous

08/03/07 20:25:27 changed by anonymous

08/09/07 23:55:50 changed by dsvcxvxcvxcv

<a href=" http://bambi-woods.newimagesite.biz/index.html "> bambi woods </a> <a href=" http://christine-dolce.newimagesite.biz/index.html "> christine dolce </a> <a href=" http://barbara-eden.newimagesite.biz/index.html "> barbara eden </a> <a href=" http://barbara-dare.newimagesite.biz/index.html "> barbara dare </a> <a href=" http://shemar-moore-dui.newimagesite.biz/index.html "> shemar moore dui </a> <a href=" http://shemar-moore.newimagesite.biz/index.html "> shemar moore </a> <a href=" http://jodie-moore.newimagesite.biz/index.html "> jodie moore </a> <a href=" http://maria-moore.newimagesite.biz/index.html "> maria moore </a> <a href=" http://barbi-benton.newimagesite.biz/index.html "> barbi benton </a> <a href=" http://carmel-moore.newimagesite.biz/index.html "> carmel moore </a>

08/10/07 01:32:43 changed by xcvxcvsdf

<a href=" http://barbie-griffin.newimagesite.biz/index.html "> barbie griffin </a> <a href=" http://lanny-barbie.newimagesite.biz/index.html "> lanny barbie </a> <a href=" http://barbie-bridges.newimagesite.biz/index.html "> barbie bridges </a> <a href=" http://haley-bennett.newimagesite.biz/index.html "> haley bennett </a> <a href=" http://bea-flora.newimagesite.biz/index.html "> bea flora </a> <a href=" http://brandi-belle.newimagesite.biz/index.html "> brandi belle </a> <a href=" http://bettie-ballhaus.newimagesite.biz/index.html "> bettie ballhaus </a> <a href=" http://trump-quits.newimagesite.biz/index.html "> trump quits </a> <a href=" http://ash-webcam-girl.newimagesite.biz/index.html "> ash webcam girl </a> <a href=" http://penelope-black-diamond.newimagesite.biz/index.html "> penelope black diamond </a>

08/10/07 03:14:09 changed by sfdvcxv

<a href=" http://bobbi-billard.newimagesite.biz/index.html "> bobbi billard </a> <a href=" http://rachel-starr.newimagesite.biz/index.html "> rachel starr </a> <a href=" http://penelope-jimenez.newimagesite.biz/index.html "> penelope jimenez </a> <a href=" http://emma-starr.newimagesite.biz/index.html "> emma starr </a> <a href=" http://allanah-starr.newimagesite.biz/index.html "> allanah starr </a> <a href=" http://bobby-lashley.newimagesite.biz/index.html "> bobby lashley </a> <a href=" http://brande-roderick-gallery.newimagesite.biz/index.html "> brande roderick gallery </a> <a href=" http://brandi-love.newimagesite.biz/index.html "> brandi love </a> <a href=" http://brandy-talore.newimagesite.biz/index.html "> brandy talore </a> <a href=" http://katie-morgan.newimagesite.biz/index.html "> katie morgan </a>

08/10/07 04:34:00 changed by safwer

<a href=" http://brandy-dahl.newimagesite.biz/index.html "> brandy dahl </a> <a href=" http://cassandra-lynn.newimagesite.biz/index.html "> cassandra lynn </a> <a href=" http://ginger-lynn.newimagesite.biz/index.html "> ginger lynn </a> <a href=" http://mandy-lynn.newimagesite.biz/index.html "> mandy lynn </a> <a href=" http://bree-olsen.newimagesite.biz/index.html "> bree olsen </a> <a href=" http://jennifer-lynn-jackson.newimagesite.biz/index.html "> jennifer lynn jackson </a> <a href=" http://bree-olson.newimagesite.biz/index.html "> bree olson </a> <a href=" http://bridgette-kerkove.newimagesite.biz/index.html "> bridgette kerkove </a> <a href=" http://briana-banks.newimagesite.biz/index.html "> briana banks </a> <a href=" http://bridgette-wilson.newimagesite.biz/index.html "> bridgette wilson </a>

08/10/07 06:15:37 changed by vxcvcxvb

<a href=" http://brittany-binger.newimagesite.biz/index.html "> brittany binger </a> <a href=" http://brittany-daniel.newimagesite.biz/index.html "> brittany daniel </a> <a href=" http://brooke-berry.newimagesite.biz/index.html "> brooke berry </a> <a href=" http://brooke-haven.newimagesite.biz/index.html "> brooke haven </a> <a href=" http://brooke-mueller.newimagesite.biz/index.html "> brooke mueller </a> <a href=" http://brooke-richards.newimagesite.biz/index.html "> brooke richards </a> <a href=" http://brooke-marks.newimagesite.biz/index.html "> brooke marks </a> <a href=" http://buffy-tyler.newimagesite.biz/index.html "> buffy tyler </a> <a href=" http://brooke-banx.newimagesite.biz/index.html "> brooke banx </a> <a href=" http://buffy-the-body.newimagesite.biz/index.html "> buffy the body </a>

08/10/07 10:13:52 changed by dsvcxvxcvxcv

<a href=" http://sabrina-sabrok.newimagesite.biz/index.html "> sabrina sabrok </a> <a href=" http://celebrity-feet.newimagesite.biz/index.html "> celebrity feet </a> <a href=" http://kelly-monaco.newimagesite.biz/index.html "> kelly monaco </a> <a href=" http://kat-young.newimagesite.biz/index.html "> kat young </a> <a href=" http://denise-milani.newimagesite.biz/index.html "> denise milani </a> <a href=" http://susana-spears.newimagesite.biz/index.html "> susana spears </a> <a href=" http://danielle-fishel.newimagesite.biz/index.html "> danielle fishel </a> <a href=" http://jill-nicolini.newimagesite.biz/index.html "> jill nicolini </a> <a href=" http://in-bed-with-faith.newimagesite.biz/index.html "> in bed with faith </a> <a href=" http://dream-kelly.newimagesite.biz/index.html "> dream kelly </a>

08/10/07 12:55:57 changed by sfdvcxv

<a href=" http://justine-joli.newimagesite.biz/index.html "> justine joli </a> <a href=" http://lorna-morgan.newimagesite.biz/index.html "> lorna morgan </a> <a href=" http://kerry-marie.newimagesite.biz/index.html "> kerry marie </a> <a href=" http://melissa-doll.newimagesite.biz/index.html "> melissa doll </a> <a href=" http://avy-scott.newimagesite.biz/index.html "> avy scott </a> <a href=" http://andie-valentino.newimagesite.biz/index.html "> andie valentino </a> <a href=" http://katie-fey.newimagesite.biz/index.html "> katie fey </a> <a href=" http://amy-rose.newimagesite.biz/index.html "> amy rose </a> <a href=" http://lil-kim.newimagesite.biz/index.html "> lil kim </a> <a href=" http://melissa-puente.newimagesite.biz/index.html "> melissa puente </a>

08/10/07 14:14:51 changed by safwer

<a href=" http://justine-greiner.newimagesite.biz/index.html "> justine greiner </a> <a href=" http://jenna-lewis.newimagesite.biz/index.html "> jenna lewis </a> <a href=" http://bobby-valentino.newimagesite.biz/index.html "> bobby valentino </a> <a href=" http://jada-fire.newimagesite.biz/index.html "> jada fire </a> <a href=" http://randy-blue.newimagesite.biz/index.html "> randy blue </a> <a href=" http://gang-fights.newimagesite.biz/index.html "> gang fights </a> <a href=" http://pure-dee.newimagesite.biz/index.html "> pure dee </a> <a href=" http://codi-milo.newimagesite.biz/index.html "> codi milo </a> <a href=" http://lena-headey.newimagesite.biz/index.html "> lena headey </a> <a href=" http://silver-daddies.newimagesite.biz/index.html "> silver daddies </a>

08/11/07 08:52:01 changed by dsvcxvxcvxcv

<a href=" http://chilli-vanilla.placy.biz/index.html "> chilli vanilla </a> <a href=" http://chloe-jones.placy.biz/index.html "> chloe jones </a> <a href=" http://chloe-18.placy.biz/index.html "> chloe 18 </a> <a href=" http://chloe-nicole.placy.biz/index.html "> chloe nicole </a> <a href=" http://kianna-dior.placy.biz/index.html "> kianna dior </a> <a href=" http://chrissy-moran.placy.biz/index.html "> chrissy moran </a> <a href=" http://calvert-collins.placy.biz/index.html "> calvert collins </a> <a href=" http://christi-shake.placy.biz/index.html "> christi shake </a> <a href=" http://christie-kerr-kissing-trophy.placy.biz/index.html "> christie kerr kissing trophy </a> <a href=" http://natalie-sparks.placy.biz/index.html "> natalie sparks </a>

08/11/07 13:16:20 changed by xcvxcvsdf

<a href=" http://christine-mendoza.placy.biz/index.html "> christine mendoza </a> <a href=" http://amateur-allure.placy.biz/index.html "> amateur allure </a> <a href=" http://christy-canyon.placy.biz/index.html "> christy canyon </a> <a href=" http://christine-young.placy.biz/index.html "> christine young </a> <a href=" http://christy-hemme.placy.biz/index.html "> christy hemme </a> <a href=" http://adriana-sage.placy.biz/index.html "> adriana sage </a> <a href=" http://cindy-margolis.placy.biz/index.html "> cindy margolis </a> <a href=" http://cindy-lauper.placy.biz/index.html "> cindy lauper </a> <a href=" http://cindy-movies.placy.biz/index.html "> cindy movies </a> <a href=" http://claire-danes.placy.biz/index.html "> claire danes </a>

08/12/07 09:17:19 changed by cvxzvcxv

[url=http://mugencharacters.fora.pl/] mugen characters /url <a href=" http://mugencharacters.fora.pl/ "> mugen characters </a> http://mugencharacters.fora.pl mugen characters

01/31/08 19:39:12 changed by mbailey

  • status changed from reopened to closed.
  • resolution set to fixed.

nginx now supported in deprec2 postgres will need a new postgres.rb file