diff --git a/.gitignore b/.gitignore index e87e00f..048a7c2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ secret_token config/app_config.yml config/newrelic.yml tmp/ +.vagrant diff --git a/Gemfile b/Gemfile index 5275638..b49efda 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ gem 'rvm-capistrano' gem 'sanitize' gem "recaptcha", :require => "recaptcha/rails" gem 'dynamic_form' +gem 'unicorn' # apis gem 'fitgem' diff --git a/Gemfile.lock b/Gemfile.lock index 8672ca9..ed73e2b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -111,6 +111,7 @@ GEM railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.0) + kgio (2.8.0) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -168,6 +169,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) + raindrops (0.11.0) rake (10.1.0) rdoc (3.12.2) json (~> 1.4) @@ -224,6 +226,10 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.37) + unicorn (4.6.2) + kgio (~> 2.6) + rack + raindrops (~> 0.7) vegas (0.1.11) rack (>= 1.0.0) will_paginate (3.0.4) @@ -269,5 +275,6 @@ DEPENDENCIES sunspot_rails sunspot_solr sunspot_test! + unicorn vegas will_paginate diff --git a/Vagrantfile b/Vagrantfile index dc29267..8f4a90d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -29,7 +29,7 @@ Vagrant::Config.run do |config| # Forward a port from the guest to the host, which allows for outside # computers to access the VM, whereas host only networking does not. - config.vm.forward_port 3000, 4000 + config.vm.forward_port 80, 9000 # Share an additional folder to the guest VM. The first argument is # an identifier, the second is the path on the guest to mount the diff --git a/config.ru b/config.ru index 128017d..a63637b 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,2 @@ require ::File.expand_path('../config/environment', __FILE__) - -run Rack::URLMap.new \ - "/" => Snpr::Application +run Snpr::Application diff --git a/config/deploy.rb b/config/deploy.rb index 4eb1735..d4a3c07 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -18,4 +18,8 @@ set :rvm_type, :system after 'deploy:restart', 'unicorn:reload' after 'deploy:restart', 'unicorn:restart' +load 'lib/capistrano/tasks/helpers' +load 'lib/capistrano/tasks/base' +after 'deploy:update', 'deploy:migrate' +after 'deploy:create_shared_dirs', 'deploy:assets:precompile' diff --git a/config/deploy/vagrant.rb b/config/deploy/vagrant.rb index 7f9028e..7d0a6e3 100644 --- a/config/deploy/vagrant.rb +++ b/config/deploy/vagrant.rb @@ -1,2 +1,5 @@ server "localhost:2222", :app, :web, :db, :primary => true set :deploy_to, "/srv/www/#{application}" +set :scm, :none +set :repository, "." +set :deploy_via, :copy diff --git a/config/environments/production.rb b/config/environments/production.rb index 2cd041e..90db83d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -30,7 +30,7 @@ Snpr::Application.configure do # Disable Rails's static asset server # In production, Apache or nginx will already do this - #config.serve_static_assets = false + config.serve_static_assets = false # Enable serving of images, stylesheets, and javascripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" diff --git a/config/unicorn/production.rb b/config/unicorn/production.rb index 91a5b76..1b62670 100644 --- a/config/unicorn/production.rb +++ b/config/unicorn/production.rb @@ -1,17 +1,14 @@ -# ------------------------------------------------------------------------------ -# Sample rails 3 config -# ------------------------------------------------------------------------------ - # Set your full path to application. -app_path = "/srv/www/snpr" +app_path = "/srv/www/snpr/current" # Set unicorn options worker_processes 5 preload_app true timeout 180 +#listen "/tmp/snpr_unicorn.sock", :backlog => 64 listen "127.0.0.1:9000" -# Spawn unicorn master worker for user apps (group: apps) +# Spawn unicorn master worker for user snpr (group: snpr) user 'snpr', 'snpr' # Fill path to your app diff --git a/lib/capistrano/tasks/base.rb b/lib/capistrano/tasks/base.rb new file mode 100644 index 0000000..9b97cc7 --- /dev/null +++ b/lib/capistrano/tasks/base.rb @@ -0,0 +1,12 @@ +namespace :deploy do + task :set_symlinks do + ln("#{shared_path}/config/app_config.yml", "#{release_path}/config/app_config.yml") + ln("#{shared_path}/config/database.yml", "#{release_path}/config/database.yml") + end + after "deploy:create_shared_dirs", "deploy:set_symlinks" + + task :create_shared_dirs do + mkdir("#{shared_path}/config") + end + after "deploy:update", "deploy:create_shared_dirs" +end diff --git a/lib/capistrano/tasks/helpers.rb b/lib/capistrano/tasks/helpers.rb new file mode 100644 index 0000000..71e54fa --- /dev/null +++ b/lib/capistrano/tasks/helpers.rb @@ -0,0 +1,7 @@ +def ln(src, dst) + run("ln -snf '#{src}' '#{dst}'") +end + +def mkdir(path) + run("[ -d '#{path}' ] || mkdir -p '#{path}'") +end