unicorn to production

This commit is contained in:
Nicolas Bally 2012-02-09 18:53:16 +01:00
parent 465aeb7c23
commit 6d01549ad9
5 changed files with 470 additions and 35 deletions

12
.gitignore vendored
View File

@ -1,10 +1,8 @@
.bundle
db/*.sqlite3
db/schema.rb
log/*.log
tmp/**/*
public/assets/stylesheets/*
.sass-cache/**
tmp/
.sass-cache/
.DS_Store
private_medias/
public/public_medias

View File

@ -1,57 +1,68 @@
set :application, 'maisonarbre_app'
set :domain, 'www.lamaisondelarbre.fr'
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, 'ruby-1.9.3-p0'
set :rvm_type, :user
set :user, 'web'
set :application, 'www.lamaisondelarbre.fr' # use your folder app name
set :deploy_to, "/home/#{user}/apps/#{application}/" # the live app will be in the "current" subdir
set :deploy_to, "/home/#{user}/#{application}/"
set :deploy_via, :remote_cache
#set :keep_releases, 1
set :normalize_asset_timestamps, false
#use trunk to deploy to production
set :branch, "master"
set :rails_env, "production"
#production
set :domain, 'test.lamaisondelarbre.fr' # your http://publicdomain.com
role :app, domain
role :web, domain
role :db, domain, :primary => true
set :rails_env, "production"
role :app, domain
role :web, domain
role :db, domain, :primary => true
set :scm, :git
set :repository, "git@box1.quartz-agence.com:test-mda.git"
set :repository, "git@box1.quartz-agence.com:#{application}.git"
set :branch, "master"
default_run_options[:pty] = true
set :use_sudo, false
set :ssh_options, {:forward_agent => true}
after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:make_simlinks"
after "deploy:make_simlinks", "deploy:restart"
after "deploy:restart", "deploy:cleanup"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :bundle_gems do
run "cd #{deploy_to}current && bundle install"
end
task :make_simlinks do
run "rm -rf #{deploy_to}current/db/production.sqlite3"
run "ln -s #{deploy_to}shared/sqlite3_databases/production.sqlite3 #{deploy_to}current/db/production.sqlite3"
run "rm -rf #{deploy_to}current/private_medias"
run "ln -s #{deploy_to}shared/medias/private #{deploy_to}current/private_medias"
run "ln -s #{deploy_to}shared/storage/private #{deploy_to}current/private_medias"
run "rm -rf #{deploy_to}current/public/public_medias"
run "ln -s #{deploy_to}shared/medias/public #{deploy_to}current/public/public_medias"
run "ln -s #{deploy_to}shared/storage/public #{deploy_to}current/public/public_medias"
end
task :start do
sudo "service #{application} start"
end
task :stop do
run "service #{application} stop"
end
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
sudo "service #{application} restart"
end
task :migrate do
run "cd #{deploy_to}current && rake db:migrate RAILS_ENV=#{rails_env}"
end
end

21
config/nginx.conf Normal file
View File

@ -0,0 +1,21 @@
upstream maisonarbre_app_unicorn {
server unix:/home/web/maisonarbre_app/shared/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.lamaisondelarbre.fr;
root /home/web/maisonarbre_app/current/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://maisonarbre_app_unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}

10
config/unicorn.rb Normal file
View File

@ -0,0 +1,10 @@
@rails_app = "maisonarbre_app"
working_directory "/home/web/#{@rails_app}/current"
pid "/home/web/#{@rails_app}/shared/unicorn.pid"
stderr_path "/home/web/#{@rails_app}/shared/log/unicorn.log"
stdout_path "/home/web/#{@rails_app}/shared/log/unicorn.log"
listen "/home/web/#{@rails_app}/shared/tmp/unicorn.sock"
worker_processes 2
timeout 30

395
db/schema.rb Normal file
View File

@ -0,0 +1,395 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110914090746) do
create_table "admins", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "reset_password_token"
t.string "remember_token"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "username"
t.string "surname"
t.string "firstname"
t.integer "roles_mask"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "albums", :force => true do |t|
t.string "name"
t.boolean "super_admin"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "allowed_block_contents", :force => true do |t|
t.integer "block_id"
t.integer "content_type_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "block_contents", :force => true do |t|
t.integer "style"
t.integer "nbr_columns"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "blocks", :force => true do |t|
t.string "block_name"
t.string "blockable_type"
t.integer "blockable_id"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "break_contents", :force => true do |t|
t.boolean "line"
t.integer "height"
t.string "style"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "cel_tables", :force => true do |t|
t.integer "position"
t.integer "style"
t.integer "table_row_id"
t.integer "table_content_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "cible_aliases", :force => true do |t|
t.integer "menu_item_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "cible_types", :force => true do |t|
t.string "slug"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "cible_urls", :force => true do |t|
t.string "url"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "content_types", :force => true do |t|
t.string "slug"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "data_files", :force => true do |t|
t.string "file"
t.string "name"
t.string "slug"
t.string "description"
t.integer "file_folder_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "download_contents", :force => true do |t|
t.string "title"
t.string "style"
t.text "description"
t.integer "data_file_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "dynamic_contents", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "external_links", :force => true do |t|
t.string "title"
t.text "description"
t.string "url"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "file_folders", :force => true do |t|
t.string "name"
t.boolean "super_admin"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "gallery_contents", :force => true do |t|
t.string "name"
t.text "description"
t.integer "style"
t.integer "nbr_img"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "gallery_images", :force => true do |t|
t.string "title"
t.text "description"
t.integer "position"
t.integer "image_file_id"
t.integer "gallery_content_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "home_blocks", :force => true do |t|
t.string "title"
t.string "description"
t.integer "cible_id"
t.string "cible_type"
t.string "slug"
t.integer "home_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "homes", :force => true do |t|
t.string "slug"
t.integer "promotion_1_id"
t.integer "promotion_2_id"
t.integer "promotion_3_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "html_contents", :force => true do |t|
t.text "content"
t.string "style"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "image_contents", :force => true do |t|
t.integer "image_file_id"
t.integer "width"
t.integer "height"
t.string "alignement"
t.boolean "expandable"
t.string "style"
t.string "alt"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "image_files", :force => true do |t|
t.string "file"
t.string "name"
t.string "slug"
t.text "description"
t.string "tags"
t.integer "album_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "img_link_contents", :force => true do |t|
t.text "title"
t.text "description"
t.integer "image_file_id"
t.integer "cible_id"
t.string "cible_type"
t.boolean "with_cible"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "inscrits", :force => true do |t|
t.string "email"
t.string "verify_key"
t.boolean "enabled"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "link_contents", :force => true do |t|
t.integer "type"
t.string "name"
t.string "title"
t.boolean "popup"
t.string "url"
t.string "style"
t.integer "cible_id"
t.string "cible_type"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "map_contents", :force => true do |t|
t.string "address"
t.string "name"
t.integer "view"
t.boolean "info_bule"
t.integer "zoom"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "menu_aliases", :force => true do |t|
t.integer "menu_item_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "menu_articles", :force => true do |t|
t.integer "article_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "menu_folders", :force => true do |t|
t.integer "folder_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "menu_item_content_types", :force => true do |t|
t.string "name"
t.string "slug"
t.boolean "super_admin"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "menu_items", :force => true do |t|
t.string "name"
t.string "slug"
t.string "permalink"
t.integer "parent_id"
t.integer "position"
t.boolean "super_admin"
t.boolean "enabled"
t.boolean "visible"
t.boolean "deleted"
t.integer "menu_id"
t.integer "menu_content_id"
t.string "menu_content_type"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "menu_urls", :force => true do |t|
t.string "url"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "menus", :force => true do |t|
t.string "name"
t.string "max_levels"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "newsletters", :force => true do |t|
t.string "subject"
t.text "content"
t.boolean "sended"
t.boolean "send_at"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "pages", :force => true do |t|
t.text "title"
t.text "description"
t.text "keywords"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "portlets", :force => true do |t|
t.integer "block_id"
t.integer "content_id"
t.string "content_type"
t.integer "position"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "sessions", :force => true do |t|
t.string "session_id", :null => false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
create_table "table_contents", :force => true do |t|
t.integer "style"
t.integer "nbr_rows"
t.integer "nbr_cols"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "table_rows", :force => true do |t|
t.integer "position"
t.integer "style"
t.integer "table_content_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "tags", :force => true do |t|
t.string "name"
t.string "slug"
t.integer "parent_id"
t.boolean "public"
t.string "taggable_type"
t.integer "taggable_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "text_contents", :force => true do |t|
t.string "style"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "title_contents", :force => true do |t|
t.text "content"
t.integer "level"
t.string "style"
t.datetime "created_at"
t.datetime "updated_at"
end
end