Capistrano deploy fails after I changed the repository URL
I gotta say I’m not sure, since I haven’t been able to test this but this should work:
cap deploy:cleanup -s keep_releases=0
Since it wipes every release (cache) from the server.
Apparently you will also need to remove shared/cached-copy
, because this doesn’t seem to be cleaned by the Capistrano call above according to the comment below.
Capistrano error when change repository using git
With capistrano 3, to avoid deleting the repo folder :
Change the repo URL in your
config/deploy.rb
, as the OP already didSSH to your server inside and change the remote URL of the git repo :
ssh user@server.com
# Go the capistrano deploy root
cd /capistrano/deploy/root/folder
# Go inside the folder names *repo*
cd repo
# Manually change the git remote
git remote set-url origin ...
Capistrano Deploy Fails To Find Github Repository
By default, capistrano deploys the master
branch. But your repository contains only a main
branch.
Just configure capistrano to deploy from the main
branch.
set :branch, "main"
Deploying Rails App with Capistrano - ERROR: Repository not found.
I had to change my /config/deploy.rb
file in order for Capistrano to actually use the work_rsa
private key :
set :ssh_options, { forward_agent: false, paranoid: true, keys: "~/.ssh/work_rsa" }
Capistrano looking for old Github repo after deploy.rb changed to new repo
It turns out there was still a reference to the original repository in the .git/config
file.
I changed this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:oldusername/example.git
To this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:new_repo_user/example.git
And Capistrano started doing the right thing.
Capistrano deploy hangs at check_changes step
Solution turned out to be simple. But it required a lot of useless googling before I finally figured it out by trial-and-error. Posting this as a reference for others who may find themselves in this situation.
The fix was to ssh into the server and remove the repo
directory from the project root:
cd /home/myproject
mv -v repo /tmp/cap-repo
After this, I was able to run the cap deploy
command successfully.
I would be interested in hearing an explanation for the [m
and :[K
output.
Capistrano 3: After deployment is not refreshed code (website stays as prior the deploy)
You can create a task that does this restarting step for you and call it after the deployment process. Maybe it can run a shell script with the required commands to restart Unicorn. Put the commands you use in the script and call it via the Capistrano task. Something like this:
desc 'Restarts the application calling the appropriate Unicorn shell script.'
task :restart_unicorn do
on roles(:app) do
execute '/etc/init.d/restart_unicorn.sh'
end
end
after 'deploy:published', 'restart_unicorn'
More details here. Don't forget to modify the shell file permissions to allow execution. The task code can be in your deploy.rb
file, but I recommend moving it to a specific Capistrano tasks file to keep your code organized. Hope this helps!
PS.: Take a look at the Capistrano flow too. Actually, you can create tasks to run before or after any part of the process.
Related Topics
Replicating Xml Request with Savon/Ruby
Rails: How to Pass Custom Params to a Controller Method
Cannot Install Ruby 1.9.3 on a Clean Lion Install
Understanding Usage of Symbols in Routes.Rb Files
Issue with Precision of Ruby Math Operations
Error Occurs When Trying to Install Homebrew on a MAC for Ruby on Rails
Rails "Template Is Missing" Error
Rails Form_For Never Invokes the Create Controller Action to Use Redirect_To
Tilt (Kramdown) Preventing Erb Processing When Rendering Markdown
Ruby, Value Bucketing, Beautify Code
Rails in Rendering Unnecessary Information
Login Session Data Not Persisting in Rails 6
How to Collect Real-Time Tweets
Sum of Arrays of Different Size
Determining Type of an Object in Ruby
Rspec Error 'Report_Activate_Error': Could Not Find Rubygem Rspec-Core (>=0) (Gem:Loaderror)