Browse files

upgrade to rails 3.2.3 and modify deploy script

  • Loading branch information...
1 parent ff50827 commit 93457b22d557389688be17aaf9975aec10b23976 @chawei committed Apr 2, 2012
Showing with 246 additions and 109 deletions.
  1. +3 −7 Gemfile
  2. +102 −82 Gemfile.lock
  3. +1 −1 app/models/film.rb
  4. +3 −17 config/deploy.rb
  5. +133 −0 config/deploy.rb.linode
  6. +0 −1 config/environments/development.rb
  7. +4 −1 public/.htaccess
View
10 Gemfile
@@ -1,11 +1,7 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.1'
-
-# Bundle edge Rails instead:
-# gem 'rails', :git => 'git://github.com/rails/rails.git'
-
-gem 'sqlite3-ruby', '1.3.1', :require => 'sqlite3'
+gem 'rails', '3.2.3'
+gem 'sqlite3'
# Use unicorn as the web server
# gem 'unicorn'
@@ -21,7 +17,7 @@ gem 'capistrano'
gem 'simple-navigation'
gem 'friendly_id', '~> 3.1'
-gem 'authlogic', '2.1.6'
+gem 'authlogic'
gem 'will_paginate', '~> 3.0.pre4'
gem 'paperclip'
gem 'acts_as_list'
View
184 Gemfile.lock
@@ -1,117 +1,137 @@
GEM
remote: http://rubygems.org/
specs:
- abstract (1.0.0)
- actionmailer (3.0.1)
- actionpack (= 3.0.1)
- mail (~> 2.2.5)
- actionpack (3.0.1)
- activemodel (= 3.0.1)
- activesupport (= 3.0.1)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.4.1)
- rack (~> 1.2.1)
- rack-mount (~> 0.6.12)
- rack-test (~> 0.5.4)
- tzinfo (~> 0.3.23)
- activemodel (3.0.1)
- activesupport (= 3.0.1)
- builder (~> 2.1.2)
- i18n (~> 0.4.1)
- activerecord (3.0.1)
- activemodel (= 3.0.1)
- activesupport (= 3.0.1)
- arel (~> 1.0.0)
- tzinfo (~> 0.3.23)
- activeresource (3.0.1)
- activemodel (= 3.0.1)
- activesupport (= 3.0.1)
- activesupport (3.0.1)
- acts_as_list (0.1.2)
- arel (1.0.1)
- activesupport (~> 3.0.0)
- authlogic (2.1.6)
- activesupport
- babosa (0.2.0)
- builder (2.1.2)
- capistrano (2.5.19)
+ actionmailer (3.2.3)
+ actionpack (= 3.2.3)
+ mail (~> 2.4.4)
+ actionpack (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.3)
+ activesupport (= 3.2.3)
+ builder (~> 3.0.0)
+ activerecord (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ activesupport (3.2.3)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ acts_as_list (0.1.5)
+ arel (3.0.2)
+ authlogic (3.1.0)
+ activerecord (>= 3.0.7)
+ activerecord (>= 3.0.7)
+ babosa (0.3.7)
+ builder (3.0.0)
+ capistrano (2.11.2)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
- net-ssh-gateway (>= 1.0.0)
- columnize (0.3.2)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- friendly_id (3.1.7)
- babosa (~> 0.2.0)
- highline (1.6.1)
- i18n (0.4.2)
- linecache (0.43)
- mail (2.2.9)
- activesupport (>= 2.3.6)
- i18n (~> 0.4.1)
+ net-ssh-gateway (>= 1.1.0)
+ cocaine (0.2.1)
+ columnize (0.3.6)
+ erubis (2.7.0)
+ friendly_id (3.3.2.0)
+ babosa (~> 0.3.0)
+ highline (1.6.11)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.3)
+ json (1.6.6)
+ linecache (0.46)
+ rbx-require-relative (> 0.0.4)
+ mail (2.4.4)
+ i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.16)
+ mime-types (1.18)
+ multi_json (1.2.0)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
- net-ssh (2.1.0)
- net-ssh-gateway (1.0.1)
+ net-ssh (2.3.0)
+ net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
- paperclip (2.3.5)
- activerecord
- activesupport
- polyglot (0.3.1)
- rack (1.2.1)
- rack-mount (0.6.13)
- rack (>= 1.0.0)
- rack-test (0.5.6)
+ paperclip (3.0.1)
+ activemodel (>= 3.0.0)
+ activerecord (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ cocaine (>= 0.0.2)
+ mime-types
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
rack (>= 1.0)
- rails (3.0.1)
- actionmailer (= 3.0.1)
- actionpack (= 3.0.1)
- activerecord (= 3.0.1)
- activeresource (= 3.0.1)
- activesupport (= 3.0.1)
- bundler (~> 1.0.0)
- railties (= 3.0.1)
- railties (3.0.1)
- actionpack (= 3.0.1)
- activesupport (= 3.0.1)
- rake (>= 0.8.4)
- thor (~> 0.14.0)
- rake (0.8.7)
+ rails (3.2.3)
+ actionmailer (= 3.2.3)
+ actionpack (= 3.2.3)
+ activerecord (= 3.2.3)
+ activeresource (= 3.2.3)
+ activesupport (= 3.2.3)
+ bundler (~> 1.0)
+ railties (= 3.2.3)
+ railties (3.2.3)
+ actionpack (= 3.2.3)
+ activesupport (= 3.2.3)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rbx-require-relative (0.0.9)
+ rdoc (3.12)
+ json (~> 1.4)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
- simple-navigation (3.0.2)
+ simple-navigation (3.7.0)
activesupport (>= 2.3.2)
- sqlite3-ruby (1.3.1)
- state_machine (0.9.4)
- thor (0.14.4)
- treetop (1.4.8)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
+ state_machine (1.1.2)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.23)
- will_paginate (3.0.pre2)
+ tzinfo (0.3.32)
+ will_paginate (3.0.3)
PLATFORMS
ruby
DEPENDENCIES
acts_as_list
- authlogic (= 2.1.6)
+ authlogic
capistrano
friendly_id (~> 3.1)
paperclip
- rails (= 3.0.1)
+ rails (= 3.2.3)
ruby-debug
simple-navigation
- sqlite3-ruby (= 1.3.1)
+ sqlite3
state_machine
will_paginate (~> 3.0.pre4)
View
2 app/models/film.rb
@@ -17,7 +17,7 @@ class Film < ActiveRecord::Base
has_one :video
has_attached_file :film_video
- named_scope :public, :conditions => { :draft => false }
+ scope :public, :conditions => { :draft => false }
after_create :remove_redundant_videos
View
20 config/deploy.rb
@@ -1,33 +1,19 @@
require 'bundler/capistrano'
-# This will specify the rvm version
-require 'rvm/capistrano'
-set :rvm_ruby_string, 'ruby-1.8.7-p302' # Defaults to 'default'
-
-# http://blog.futureshock-ed.com/2009/05/draft-deploying-ruby-on-rails-app-to.html
-
-#############################################################
-# This file is designed as a starting point to use
-# capistrano to deploy the trunk of tracks to a webhost
-# where it is served using Phusion Passenger. For more
-# info on getting started with Passenger, see
-# http://www.modrails.com/
-#############################################################
-
#############################################################
# Servers
#############################################################
-set :user, "rails3-deployer"
-set :domain, "dearstudio.com"
+set :user, "weihsing"
+set :domain, "weihsingyang.com"
server domain, :app, :web
role :db, domain, :primary => true
#############################################################
# Application
#############################################################
-set :application, "yang-dev"
+set :application, "portfolio"
set :deploy_to, "/home/#{user}/apps/#{application}"
#############################################################
View
133 config/deploy.rb.linode
@@ -0,0 +1,133 @@
+require 'bundler/capistrano'
+
+# This will specify the rvm version
+require 'rvm/capistrano'
+set :rvm_ruby_string, 'ruby-1.8.7-p302' # Defaults to 'default'
+
+# http://blog.futureshock-ed.com/2009/05/draft-deploying-ruby-on-rails-app-to.html
+
+#############################################################
+# This file is designed as a starting point to use
+# capistrano to deploy the trunk of tracks to a webhost
+# where it is served using Phusion Passenger. For more
+# info on getting started with Passenger, see
+# http://www.modrails.com/
+#############################################################
+
+#############################################################
+# Servers
+#############################################################
+
+set :user, "rails3-deployer"
+set :domain, "dearstudio.com"
+server domain, :app, :web
+role :db, domain, :primary => true
+
+#############################################################
+# Application
+#############################################################
+
+set :application, "yang-dev"
+set :deploy_to, "/home/#{user}/apps/#{application}"
+
+#############################################################
+# Settings
+#############################################################
+
+default_run_options[:pty] = true
+ssh_options[:forward_agent] = true
+set :use_sudo, false
+set :scm_verbose, true
+set :rails_env, "production"
+
+# Less releases, less space wasted
+set :keep_releases, 5
+
+#############################################################
+# Git
+#############################################################
+
+set :scm, :git
+set :branch, "master"
+set :repository, "git@github.com:chawei/basic-portfolio.git"
+set :deploy_via, :remote_cache
+# If you have public like github.com then use :remote_cache
+# set :deploy_via, :copy # if you server does NOT have direct access to the repository (default)
+
+#############################################################
+# Passenger
+#############################################################
+
+namespace :deploy do
+ desc "Deploy with Migrations"
+ task :default do
+ set :migrate_target, :latest
+ update_code
+ migrate
+ symlink
+ restart
+ end
+
+ desc "Symlink db"
+ task :before_migrate do
+ run "ln -s #{shared_path}/db/production.sqlite3 #{release_path}/db/production.sqlite3"
+ end
+
+ desc "Symlink config files and db"
+ task :before_symlink do
+ #run "rm #{release_path}/public/.htaccess" #not compatible with Passenger
+ #run "ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml"
+ #run "ln -s #{shared_path}/config/environment.rb #{release_path}/config/environment.rb"
+ end
+
+ # Restart passenger on deploy
+ desc "Restarting mod_rails with restart.txt"
+ task :restart, :roles => :app, :except => { :no_release => true } do
+ run "touch #{current_path}/tmp/restart.txt"
+ end
+
+ desc "Create SQLite db in shared folder"
+ task :create_db do
+ run "mkdir -p #{shared_path}/db; touch #{shared_path}/db/production.sqlite3"
+ end
+
+ [:start, :stop].each do |t|
+ desc "#{t} task is a no-op with mod_rails"
+ task t, :roles => :app do ; end
+ end
+end
+
+before "deploy:cold", "deploy:create_db"
+
+namespace :db do
+ desc "Dumps the #{rails_env} database to db/#{rails_env}_data.sql on the remote server"
+ task :remote_db_dump, :roles => :db, :only => { :primary => true } do
+ run "cd #{deploy_to}/#{current_dir} && " +
+ "rake RAILS_ENV=#{rails_env} db:dump_sql --trace"
+ end
+
+ desc "Downloads db/#{rails_env}_data.sql from the remote #{rails_env} environment to your local machine"
+ task :remote_db_download, :roles => :db, :only => { :primary => true } do
+ execute_on_servers(options) do |servers|
+ self.sessions[servers.first].sftp.connect do |tsftp|
+ tsftp.download!("#{deploy_to}/#{current_dir}/db/#{rails_env}_data.sql", "db/#{rails_env}_data.sql")
+ end
+ end
+ end
+
+ desc 'Cleans up data dump file'
+ task :remote_db_cleanup, :roles => :db, :only => { :primary => true } do
+ execute_on_servers(options) do |servers|
+ self.sessions[servers.first].sftp.connect do |tsftp|
+ tsftp.remove! "#{deploy_to}/#{current_dir}/db/#{rails_env}_data.sql"
+ end
+ end
+ end
+
+ desc "Dump, download and then clean up the #{rails_env} data dump"
+ task :remote_db_runner do
+ remote_db_dump
+ remote_db_download
+ remote_db_cleanup
+ end
+end
View
1 config/environments/development.rb
@@ -11,7 +11,6 @@
# Show full error reports and disable caching
config.consider_all_requests_local = true
- config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
View
5 public/.htaccess
@@ -1,7 +1,10 @@
# Phusion Passenger Start
PassengerEnabled on
# Phusion Passenger End
-PassengerAppRoot /home/rails3-deployer/apps/yang-dev/current
+# Linode Setting
+# PassengerAppRoot /home/rails3-deployer/apps/yang-dev/current
+PassengerAppRoot /home/weihsing/apps/portfolio/current
+
AddType font/opentype .otf
AddType font/truetype .ttf

0 comments on commit 93457b2

Please sign in to comment.