Capistrano Deploy Fails After I Changed the Repository Url

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 :

  1. Change the repo URL in your config/deploy.rb, as the OP already did

  2. SSH 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



Leave a reply



Submit