From 646b85cf8fde2701a0e6031a055f0831edfd9204 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 9 Feb 2012 19:59:23 +0100 Subject: [PATCH] unicorn --- .gitignore | 12 +- Gemfile | 2 + Gemfile.lock | 46 +++-- config/deploy.rb | 107 ++++++----- config/nginx.conf | 21 ++ config/unicorn.rb | 10 + db/schema.rb | 478 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 603 insertions(+), 73 deletions(-) create mode 100644 config/nginx.conf create mode 100644 config/unicorn.rb create mode 100644 db/schema.rb diff --git a/.gitignore b/.gitignore index fa53a9a..d76bdcd 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/Gemfile b/Gemfile index e85c85a..d5386ea 100644 --- a/Gemfile +++ b/Gemfile @@ -55,3 +55,5 @@ group :test do # Pretty printed test output gem 'turn', :require => false end + +gem 'unicorn' diff --git a/Gemfile.lock b/Gemfile.lock index 47d5653..963ca8b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,7 +32,7 @@ GEM multi_json (~> 1.0) acts_as_list (0.1.4) acts_as_tree (0.1.1) - ansi (1.4.1) + ansi (1.4.2) arel (2.2.1) bcrypt-ruby (3.0.1) builder (3.0.0) @@ -42,13 +42,14 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.1.3) - devise (1.5.2) + coffee-script-source (1.2.0) + devise (2.0.1) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) + railties (~> 3.1) warden (~> 1.1) erubis (2.7.0) - execjs (1.2.12) + execjs (1.3.0) multi_json (~> 1.0) formtastic (2.0.2) rails (~> 3.0) @@ -58,27 +59,31 @@ GEM jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) - json (1.6.3) - kaminari (0.12.4) - rails (>= 3.0.0) + json (1.6.5) + kaminari (0.13.0) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) + railties (>= 3.0.0) + kgio (2.7.2) libv8 (3.3.10.4) mail (2.3.0) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - meta_search (1.1.1) - actionpack (~> 3.1.0) - activerecord (~> 3.1.0) - activesupport (~> 3.1.0) + meta_search (1.1.3) + actionpack (~> 3.1) + activerecord (~> 3.1) + activesupport (~> 3.1) polyamorous (~> 0.5.0) mime-types (1.17.2) mimetype-fu (0.1.2) multi_json (1.0.4) - orm_adapter (0.0.5) + mysql2 (0.3.11) + orm_adapter (0.0.6) polyamorous (0.5.0) activerecord (~> 3.0) polyglot (0.3.3) - rack (1.3.5) + rack (1.3.6) rack-cache (1.0.3) rack (>= 0.4) rack-mount (0.8.3) @@ -102,11 +107,12 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) + raindrops (0.8.0) rake (0.9.2.2) rdoc (3.12) json (~> 1.4) rmagick (2.13.1) - sass (3.1.12) + sass (3.1.14) sass-rails (3.1.5) actionpack (~> 3.1.0) railties (~> 3.1.0) @@ -126,14 +132,19 @@ GEM treetop (1.4.10) polyglot polyglot (>= 0.3.1) - turn (0.8.3) + turn (0.9.2) ansi tzinfo (0.3.31) - uglifier (1.2.0) + uglifier (1.2.3) execjs (>= 0.3.0) multi_json (>= 1.0.2) + unicorn (4.2.0) + kgio (~> 2.6) + rack + raindrops (~> 0.7) warden (1.1.0) rack (>= 1.0) + yaml_db (0.2.2) PLATFORMS ruby @@ -151,6 +162,7 @@ DEPENDENCIES kaminari meta_search mimetype-fu + mysql2 rails (= 3.1.0) rmagick sass-rails (~> 3.1.0.rc) @@ -159,3 +171,5 @@ DEPENDENCIES therubyracer turn uglifier + unicorn + yaml_db diff --git a/config/deploy.rb b/config/deploy.rb index a5212fd..278e4e2 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,61 +1,68 @@ -set :user, 'web' - -set :application, 'www.pharmacieboissier.com' # use your folder app name -set :deploy_to, "/home/#{user}/apps/#{application}/" # the live app will be in the "current" subdir -set :deploy_via, :remote_cache - -#set :keep_releases, 1 +set :application, 'boissier_app' + set :domain, 'www.pharmacieboissier.com' -#use trunk to deploy to production - set :branch, "master" - set :rails_env, "production" + $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) -#production - set :domain, 'www.pharmacieboissier.com' # your http://publicdomain.com - role :app, domain - role :web, domain - role :db, domain, :primary => true + require "rvm/capistrano" + + set :rvm_ruby_string, 'ruby-1.9.3-p0' + set :rvm_type, :user + + set :user, 'web' -set :scm, :git -set :repository, "git@box1.quartz-agence.com:pharmacieboissier.git" + set :deploy_to, "/home/#{user}/#{application}/" + set :deploy_via, :remote_cache -set :use_sudo, false -set :ssh_options, {:forward_agent => true} + set :normalize_asset_timestamps, false -after "deploy", "deploy:make_simlinks" -after "deploy:make_simlinks", "deploy:bundle_gems" -after "deploy:bundle_gems", "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 + set :rails_env, "production" -# 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 "rm -rf #{deploy_to}current/public/public_medias" - run "ln -s #{deploy_to}shared/medias/public #{deploy_to}current/public/public_medias" - 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')}" - end - task :migrate do - run "cd #{deploy_to} && rake db:migrate RAILS_ENV=#{rails_env}" - end -end + + role :app, domain + role :web, domain + role :db, domain, :primary => true + + set :scm, :git + set :repository, "git@box1.quartz-agence.com:#{application}.git" + set :branch, "master" + + default_run_options[:pty] = true + + + after "deploy", "deploy:bundle_gems" + after "deploy:bundle_gems", "deploy:make_simlinks" + after "deploy:make_simlinks", "deploy:restart" + after "deploy:restart", "deploy:cleanup" + + + 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/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/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 :restart, :roles => :app, :except => { :no_release => true } do + sudo "service #{application} restart" + end + task :migrate do + run "cd #{deploy_to}current && rake db:migrate RAILS_ENV=#{rails_env}" + + end + end \ No newline at end of file diff --git a/config/nginx.conf b/config/nginx.conf new file mode 100644 index 0000000..b478d29 --- /dev/null +++ b/config/nginx.conf @@ -0,0 +1,21 @@ +upstream boissier_app_unicorn { + server unix:/home/web/boissier_app/shared/tmp/unicorn.sock fail_timeout=0; +} + +server { + listen 80; + server_name www.pharmacieboissier.com; + root /home/web/boissier_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://boissier_app_unicorn; + } + + error_page 500 502 503 504 /500.html; + client_max_body_size 4G; + keepalive_timeout 10; +} diff --git a/config/unicorn.rb b/config/unicorn.rb new file mode 100644 index 0000000..ef332c3 --- /dev/null +++ b/config/unicorn.rb @@ -0,0 +1,10 @@ +@rails_app = "boissier_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 \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..8fdca7c --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,478 @@ +# encoding: UTF-8 +# 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 => 20111218164254) 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 "articles", :force => true do |t| + t.string "title" + t.string "slug" + t.text "description" + t.integer "image_file_id" + t.boolean "enabled" + t.integer "folder_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_articles", :force => true do |t| + t.integer "article_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "cible_folders", :force => true do |t| + t.integer "folder_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 "folders", :force => true do |t| + t.string "title" + t.string "slug" + t.boolean "enabled" + t.text "description" + t.integer "image_file_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "folder_type_id" + 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 "garde_contents", :force => true do |t| + t.text "column_1" + t.text "column_2" + t.text "column_3" + t.text "column_4" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "garde_lines", :force => true do |t| + t.integer "garde_content_id" + t.integer "position" + t.text "column_1" + t.text "column_2" + t.text "column_3" + t.text "column_4" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "garde_lines", ["garde_content_id"], :name => "index_garde_lines_on_garde_content_id" + + 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 "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 "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 "prescriptions", :force => true do |t| + t.string "name" + t.string "tel" + t.text "notes" + t.text "pharma_notes" + t.string "file" + t.integer "done_by" + t.boolean "read" + t.datetime "done_at" + t.datetime "delivery_at" + t.boolean "done" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "promotions", :force => true do |t| + t.string "title" + t.text "description" + t.integer "image_file_id" + t.date "month" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "promotion_type_id" + 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 "sliders", :force => true do |t| + t.integer "home_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "slides", :force => true do |t| + t.string "title" + t.text "description" + t.integer "cible_id" + t.string "cible_type" + t.integer "image_file_id" + t.integer "slider_id" + t.integer "position" + t.datetime "created_at" + t.datetime "updated_at" + end + + 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