I tried to deploy my Rails app, but I have some troubles because I have some folders in my repo git:
Server
API (my rails app)
Test
Hardware
How can I tell Capistrano that my rails app isn't in the / but is in /Server/API of the git folder?
I got solution from following code, you can try it.
set :application, 'app_name'
set :repo_url, 'repo_url'
set :deploy_to, 'folder_name'
set :repo_tree, "app_name" (THIS line)
I find the solution:
set :repo_tree, 'relative/path/from/your/repo'
Related
I'm trying to deploy using Capistrano 3.1.0.
The file deploy.rb states:
# Default deploy_to directory is /var/www/my_app
However, when I run cap production deploy I get the following error:
mkdir: cannot create directory /var/www/shared
It appears to be ignoring my app name completely and trying to create directories in the wrong place. It should be trying to create /var/www/myapp/shared/. My deploy.rb file specifically has:
set :application, 'myapp'
Am I missing something here, or is this a bug?
UPDATE: The relevant line of the Capistrano source code appears to be:
set :deploy_to, "/var/www/#{fetch(:application)}"
in defaults.rb. If I print out the value of fetch(:application) it's nil, so something is stopping my application name from being set properly.
Turns out it's a bug with a fix that hasn't yet made it into a release.
Here's the change:
https://github.com/capistrano/capistrano/blob/master/lib/capistrano/defaults.rb#L3
Make sure you have the directory structure that Capistrano requires. You can use the Capistrano itself to create it with the command:
cap deploy:setup
Or you can create it directly with something like this:
# Capistrano will use /var/www/....... where ... is the value set in
# :application, you can override this by setting the ':deploy_to' variable
deploy_to=/var/www/:application
mkdir -p ${deploy_to}
mkdir ${deploy_to}/{releases,shared}
ref.: wiki deploy:setup and Authentication and Authorisation
edit: if you set the :deploy_to after the :application, you don't need the commit you mentioned.
I thought I'd do a simple yet potentially very useful thing, and create another symlink called live, that points to an arbitrary release, and leave current at the head where it usually is:
20120519235508
20120521004833
20120521024312 <-- live
20120521025150
20120521030449 <-- current
I then configured www.mysite.com to hit
live/public
and stage.mysite.com to hit
current/public
Unfortunately both hosts seem to run the same app, and not 2 different apps. I've confirmed the httpd.conf has the correct settings and restarted it. However no change, they're both still running the same app, the app referenced by current/public to be exact.
I don't know if I have a setting wrong, or if something else needs to be restarted, or if this simply can't work as I imagined. I'm using passenger.
Can someone shed some light on this subject, because this configuration would be VERY useful to me for many projects.
Instead of creating an other symlink in the releases directory, I suggest to use the multistage extension. With this extension you can define different stages and add custom configuration to them. So instead of using one deployment directory for both staging and production, use a separate one for each other.
Add these lines to deploy.rb:
require "capistrano/ext/multistage"
set :stages, ["staging", "production"]
set :default_stage, "staging"
Remove the deploy_to variable from deploy.rb. Then create a deploy directory inside config which has files with the stage names. In this case: deploy/staging.rb and deploy/production.rb. The content of staging.rb:
set :rails_env, "staging"
set :deploy_to, "staging/capistrano"
And similarly for production.rb:
set :rails_env, "production"
set :deploy_to, "production/capistrano"
Of course change the paths in deploy_to. Then point staging.example.com to staging/capistrano/current/public and www.example.com to production/capistrano/current/public.
To do a staging deploy, execute cap staging deploy or simple cap deploy (remember, staging was set to default in deploy.rb) and cap production deploy to deploy to production.
I would like to ask you, if is possible to have as source place for capistrano in directory instead in repository.
I tried
set :scm, :none
set :repository, "."
but this gives me an error:
[err] : File name too long
It si s possible?
Thanks
yes, it's possible if the repo located on your server. just use full repo path on server where you do deployment
I'm trying to deploy my rails application by using Passenger and Capistrano on Dreamhost. I'm using Git as a version control and we bought an account from GitHub.
I have installed all required gems, Passenger and Capistrano in my local machine and I have cloned the repository of my project from GitHub in my local machine as wel.
According to Dreamhost support, they have Passenger, Ruby, Rails and etc on their server as well.
I'm currently following this article http://github.com/guides/deploying-with-capistrano for my deployment.
The following is my deploy.rb.
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
# be sure to change these
set :user, 'gituser'
set :domain, 'github.com'
set :application, 'MyProjectOnGit'
#git#github.com:MyProjectOnGit.git
# the rest should be good
set :repository, "git#github.com:MyProjectOnGit.git"
set :deploy_to, "/ruby.michaelsync.net/"
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false
set :git_enable_submodules, 1
server domain, :app, :web
role :db, domain, :primary => true
set :ssh_options, { :forward_agent => true }
namespace :deploy do
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
end
When I run "cap deploy", I'm getting the error below.
[deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: github.com (Net::SSH::AuthenticationFailed: gituser) connection failed for: github.com (Net::SSH::AuthenticationFailed: gituser)
Thanks in advance..
don't worry, you'll get it working in the end, I used to use the very same setup as yourself.... i.e. Dreamhost/Passenger/Capistrano/Git (and at one time, SVN) - it can be quite frustrating
Some things for you to do:
1) Read the following two articles by John Nunemaker # railstips.com - I used to refer to them every single time I had to setup a server on Dreamhost (the second one is the most important but the first link gives you some tips that are well worth following)
1.1) http://railstips.org/blog/archives/2008/11/23/gitn-your-shared-host-on/
1.2) http://railstips.org/blog/archives/2008/12/14/deploying-rails-on-dreamhost-with-passenger/
2) I think github is complaining about "gituser" - you do appear to set your username to "gituser" in your capfile - i would change that to your own name
3) you've got your domain down as github.com - again, this should be your own domain name and not github.... From what I recall..
4) start using heroku
good luck - hope this helps, let us know if it does or not....
cheers
You use your private url to clone your repository. Try with public clone URL
git://github.com/Myproject.git
i did to do sudo ln -s /opt/ruby/bin/packet_worker_runner /usr/bin/packet_worker_runner” and it solved the problem..
Thanks.
I'm using Capistrano and Rails 2.3.4. I've already done a deploy:cold to the remote server. Now on my local box I changed a layout file and committed it to the repository (I am using Netbeans 6 as my IDE). I type cap deploy and Capistrano runs through it's commands and tells me that it's checked out and deployed the most recent version of my code. On the server, however, the changes aren't there and when I looked at the layout file, it was using the old version not the one I just committed and supposedly deployed.
Anyone experience this?
EDIT: The weird thing is that I changed some image files and those were updated on the server, but the HTML layout I modified was not. Could it just be a cookies issue?
EDIT2: I checked the repository itself (I am using ProjectLocker) and sure enough the code is in there, modified. The issue is only that Capistrano is NOT checking it out even though it says that it is, and it's not reporting any errors.
Here is my deploy.rb file (scrubbed, of course):
# Application
set :application, "myapp"
set :deploy_to, "/var/www/html/#{application}"
# Settings
default_run_options[:pty] = true
set :use_sudo, true
# Servers
set :user, "deploy"
set :domain, "111.111.111.111"
set :runner, "deploy"
server domain, :app, :web
role :db, domain, :primary => true
# SVN
set :repository, "http://myhosting.com/svn/myapp/trunk"
set :scm_username, "wayne#mysite.com"
set :scm_password, "secret"
set :checkout, "export"
# Passenger
namespace :passenger do
desc "Restart Application"
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
end
after :deploy, "passenger:restart"
It works sometimes, it seems. For instance I made some changes to code earlier and it checked it out fine. I had an issue with it not checking out my database.yml file either; I was forced to edit it on the server.
Just a shot in the dark here, but did you actually look at the layout file or did you hit the website and then look at the webpage source?
If you are in production the layout will be cached (config.action_controller.perform_caching = true), you need to reboot the server. This does not occur in development mode by default, since the above setting is set to false.
See this for more info.