Disclaimer: i am a noob to Rails and Capistrano (but an intermediate .NET C# developer) trying to learn more.
i have been have the toughest time getting a Capistrano development process set-up. here's what i have so far for my deploy.rb:
set :application, "MyAppName"
set :domain, "domainname"
set :user, "userid"
set :repository, "svn+ssh://#{user}@#{domain}/home/#{user}/svn/#{application}/trunk"
set :rails_env, :production
set :chmod755, %w(app config db lib public vendor script tmp public/dispatch.cgi public/dispatch.fcgi public/dispatch.rb)
set :deploy_to, "/home/#{user}/apps/#{application}"
set :use_sudo, false
set :deploy_via, :checkout
set :group_writable, false
default_run_options[:pty] = true
role :app, domain
role :web, domain
role :db, domain, :primary => true
here's my Capfile:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy'
namespace :deploy do
task :restart, :roles => :app do
run "#{current_path}/script/process/reaper --dispatcher=dispatch.fcgi"
end
desc "Set the proper permissions for directories and files on HostingRails accounts"
task :after_deploy do
run(chmod755.collect do |item|
"chmod 755 #{current_path}/#{item}"
end.join(" && "))
end
end
- Rails 2.3.2 doesn't have the script/process directory so the restart task doesn't work at all. How do I fix this?
- Is there a way to set the RAILS_ENV variable in environment.rb to "production" when the application is deployed ("set :rails_env, :production" does not do it)?
- Also, am I missing anything else from these 2 files?
Best Answer
Here's my deploy.rb, which hasn't really been updated in a long time. I run two sed commands to set the environment inside my :after_update_code task. I'm certain there's an easier way to do it, but this is my current method.
Once I set up my variables, I have a bash script that runs:
That'll ask me for my password twice. Once for exporting from SVN, and once as a prompt to automatically generate my database.yml in the shared path.