I've set this up before but can't get it to work now. I want a development and production site. When I do cap deploy it'll setup a "current" symlink (not sure how I did that since for a long time it wouldn't even do that). But how do I get it to deploy and setup the necessary symlink for dev/prod?
My deploy.rb file:
#require 'bundler/capistrano'
require 'capistrano/ext/multistage'
require 'capistrano_colors'
set :stages, %w(development production)
set :default_stage, 'development'
set :application, "myapp"
set :repository, "***"
# Target directory on the server
set :deploy_to, "/var/www/#{application}"
set :scm, :git
set :deploy_via, :remote_cache
set :user, '***'
set :use_sudo, false
role :web, "68.225.130.30" # Your HTTP server, Apache/etc
role :app, "68.225.130.30" # This may be the same as your `Web` server
role :db, "68.225.130.30", :primary => true # This is where Rails migrations will run
# List of symlinks to be generated. Keys are subdirectories of release_path.
SYMLINKS = { :config => ['database.yml'],
:public => ['system'] }
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
# Not working =/
#run "touch /var/www/#{current_path}/tmp/restart.txt"
end
desc "Set up application symlinks."
task :app_symlinks do
SYMLINKS.keys.each do |key|
dir = key.to_s
SYMLINKS[key].each do |path|
run "ln -nfs #{shared_path}/#{dir}/#{path} #{release_path}/#{dir}/#{path}"
end
end
end
end
my deploy/development.rb file:
set :deploy_to, "/var/www/#{application}"
set :branch, "master"
unset :rails_env
set :rails_env, "development"
UPDATE/ANSWER:
Issue was with the current_path variable. Weird since I've tried using
set :current_path, "development"
and
set :current_path, "#{application}/development"
and it didn't work. Looks like I have to set the entire path, which seems weird since I've used the latter before.
set :current_path, "/var/www/#{application}/development"
Anyone know why?
:current_path is set by capistrano based on the :deploy_to path + the :application name. You can only use :current_path within your namespaced tasks.
In other words, it's a convenience variable used for creating symlinks, restarting servers, and other tasks.