Basics of Capistrano

1 view
Skip to first unread message

Pål Bergström

unread,
Jul 15, 2009, 3:14:16 AM7/15/09
to rubyonra...@googlegroups.com
I'm searching the net but about Capistrano, but can't get a complete
understanding. Could someone please give me some small hints :)

I have local developer environment, using git. The remote server also
has git and I have the app in root. Today I use ftp. What should I do
when I just want to send the files that are different, letting my local
app decide that, and how does the deploy.rb look like?
--
Posted via http://www.ruby-forum.com/.

Eric

unread,
Jul 15, 2009, 4:01:47 AM7/15/09
to Ruby on Rails: Talk
On Jul 15, 12:14 am, Pål Bergström <rails-mailing-l...@andreas-s.net>
wrote:
http://www.google.com/#hl=en&q=capistrano+tutorial

First link should be fine.

Pål Bergström

unread,
Jul 15, 2009, 9:47:41 AM7/15/09
to rubyonra...@googlegroups.com
Eric wrote:
> On Jul 15, 12:14�am, P�l Bergstr�m <rails-mailing-l...@andreas-s.net>

Great. I use site5. But what I don't understand; is the git repository
the same as the app directory (the article is about svn)? This would
help me a lot to understand.

Pål Bergström

unread,
Jul 15, 2009, 9:58:17 AM7/15/09
to rubyonra...@googlegroups.com
This is a great tutorial.

http://www.softiesonrails.com/2007/4/5/the-absolute-moron-s-guide-to-capistrano

But one thing I need to understand. What about git? Does that has
anything to with it? It states that nothing has to be done on the server
side, so I guess can skip git there and use it only locally. Is that
correct?

Pål Bergström

unread,
Jul 15, 2009, 11:13:27 AM7/15/09
to rubyonra...@googlegroups.com
And what happens with the db? Do I need to specify that or does it use
the values from database.yml? Can I skip the db if I want?

Marnen Laibow-Koser

unread,
Jul 15, 2009, 11:22:43 AM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
[...]

> But one thing I need to understand. What about git? Does that has
> anything to with it?

Yes, absolutely. The way most people use Capistrano, the server checks
out the code from the Git repository.


> It states that nothing has to be done on the server
> side, so I guess can skip git there and use it only locally. Is that
> correct?

I think there may be a way to set Capistrano to do that, but it's
probably not a great idea. Nothing needs to be done on the server side
*in the sense that you don't install Cap on the server*, but the server
*does* need the tools that Cap is going to try to call.

Basically, Cap logs into the server and runs a particular sequence of
commands on the server. Thus, if Cap runs "git pull" on the server, the
server will need Git installed for the command to have any effect.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 11:30:11 AM7/15/09
to rubyonra...@googlegroups.com
Marnen Laibow-Koser wrote:

> Basically, Cap logs into the server and runs a particular sequence of
> commands on the server. Thus, if Cap runs "git pull" on the server, the
> server will need Git installed for the command to have any effect.
>

I see. Git is installed on the server.

Should I make the app directory on the server a git repository too? Or
will Capistrano fix that. So probably a stupid question, but is the app
directory on the server the same as the git repository?

Marnen Laibow-Koser

unread,
Jul 15, 2009, 11:36:05 AM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
> Marnen Laibow-Koser wrote:
>
>> Basically, Cap logs into the server and runs a particular sequence of
>> commands on the server. Thus, if Cap runs "git pull" on the server, the
>> server will need Git installed for the command to have any effect.
>>
>
> I see. Git is installed on the server.

Great!

>
> Should I make the app directory on the server a git repository too? Or
> will Capistrano fix that.

Capistrano will take care of checking out the app from the repository
and doing what it needs to do. You don't need to worry about it.

> So probably a stupid question, but is the app
> directory on the server the same as the git repository?

Generally not. Capistrano will check out a working cooy to run on the
server. You probably could run the app right from the repository, but I
see no advantage and many potential problems in doing so.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 11:56:21 AM7/15/09
to rubyonra...@googlegroups.com
Marnen Laibow-Koser wrote:
> Pål Bergström wrote:

> Generally not. Capistrano will check out a working cooy to run on the
> server. You probably could run the app right from the repository, but I
> see no advantage and many potential problems in doing so.

And now I'm lost. What's the repository for on the server? And how is
that connected to the particular app root (I'm adding several domains
and apps under one main domain)?

When I use git locally, it's the same. I think. I only use git for
version control and using the branch command for testing new things. The
important thing for me is the local version. The server is just to be a
mirror of that.

Marnen Laibow-Koser

unread,
Jul 15, 2009, 12:12:13 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
> Marnen Laibow-Koser wrote:
>> Pål Bergström wrote:
>
>> Generally not. Capistrano will check out a working cooy to run on the
>> server. You probably could run the app right from the repository, but I
>> see no advantage and many potential problems in doing so.
>
> And now I'm lost. What's the repository for on the server?

The repository is a central place to store your Git data for your
project. This is a Git concept (actually, it's a general version
control concept).

> And how is
> that connected to the particular app root (I'm adding several domains
> and apps under one main domain)?

It's not connected in any particular way. The repository has to do only
with source control, and does not know anything directly about
deployment.

>
> When I use git locally, it's the same. I think. I only use git for
> version control and using the branch command for testing new things. The
> important thing for me is the local version.

That's right. And likewise on the server: Capistrano will check out a
local copy from the repository to be the actual running app instance.

> The server is just to be a
> mirror of that.

That's a *very* simplistic way of looking at it. I'd say more that your
local copy is a mirror of the server.

Really, what's the problem here? There is a repository. From it, you
check out copies for development, and Capistrano checks out copies (in
the same way) for deployment. How much simpler can it get? :)

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 12:20:43 PM7/15/09
to rubyonra...@googlegroups.com
Marnen Laibow-Koser wrote:

>
> Really, what's the problem here? There is a repository. From it, you
> check out copies for development, and Capistrano checks out copies (in
> the same way) for deployment. How much simpler can it get? :)
>

A good question. :-)

I guess I have problem understanding the basic principle.

For example, when I make a pointer at the server admin, where do I make
that? There must be a root somewhere.

Marnen Laibow-Koser

unread,
Jul 15, 2009, 12:32:25 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
[...]

> For example, when I make a pointer at the server admin, where do I make
> that? There must be a root somewhere.

Huh? What are you talking about here? I don't think I understand what
you're asking, and I certainly don't understand how it relates to the
issue at hand. Rephrase?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 3:04:03 PM7/15/09
to rubyonra...@googlegroups.com
Marnen Laibow-Koser wrote:
> Pål Bergström wrote:
> [...]
>> For example, when I make a pointer at the server admin, where do I make
>> that? There must be a root somewhere.
>
> Huh? What are you talking about here? I don't think I understand what
> you're asking, and I certainly don't understand how it relates to the
> issue at hand. Rephrase?
>
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> mar...@marnen.org

I can host several apps and domains under one main account. As they use
the same server, same dns, you have to point each domain to the app root
it belongs to.

Marnen Laibow-Koser

unread,
Jul 15, 2009, 4:00:55 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
[...]

> I can host several apps and domains under one main account. As they use
> the same server, same dns, you have to point each domain to the app root
> it belongs to.

Right. But setting up vhost root directory mappings is outside of the
scope of a typical Cap setup -- for one thing, you'll only have to do it
once per vhost, not every time you update the codebase. So how is this
related to your Capistrano questions?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 4:02:56 PM7/15/09
to rubyonra...@googlegroups.com
Btw, I'm not interested of version control on the server side. I use git
locally, but not extensively as I don't need it that much, and want to
use Capistrano to deploy the app. Can this be done?

Marnen Laibow-Koser

unread,
Jul 15, 2009, 4:05:58 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
> Btw, I'm not interested of version control on the server side.

Maybe, but pulling from Git is the simplest way for the server to get
the code.

> I use git
> locally, but not extensively as I don't need it that much,

What do you mean, you "don't need it that much"? Any development
operation -- even a solo hobby developer -- benefits from comprehensive
version control.

> and want to
> use Capistrano to deploy the app. Can this be done?

Yes. And I've been explaining how. Try it!

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 4:08:48 PM7/15/09
to rubyonra...@googlegroups.com
Marnen Laibow-Koser wrote:

> What do you mean, you "don't need it that much"? Any development
> operation -- even a solo hobby developer -- benefits from comprehensive
> version control.

I've manage without it for a very long time. And I'm not a hobby
developer. :-)

Marnen Laibow-Koser

unread,
Jul 15, 2009, 4:18:56 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
[...]

> I've manage without it for a very long time.

Then you are making life hard for yourself. Trust me on this.

(I used to work without version control too, a long time ago. I'd never
ever do that again.)

> And I'm not a hobby
> developer. :-)

I didn't say you were.

Getting back to the topic, do you understand now how to get Cap
deployment working? It's really not terribly difficult if you trust
Capistrano to do the right thing in most cases.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 4:46:13 PM7/15/09
to rubyonra...@googlegroups.com
Marnen Laibow-Koser wrote:
> Pål Bergström wrote:
> [...]
>> I've manage without it for a very long time.
>
> Then you are making life hard for yourself. Trust me on this.
>

Not really. And I have a long experience. What I like about git is
branching. But for actual version control I can manage without it. I've
used git for a while now and I've never needed to use it for going back
in code. Trust me. :-)

> Getting back to the topic, do you understand now how to get Cap
> deployment working? It's really not terribly difficult if you trust
> Capistrano to do the right thing in most cases.

Not quite. I don't think is that clear. And maybe that's why a few
people have had a hard time getting into it. Often developers, or
programmers that is, have a hard time explaining things.

And sometimes we users are just thick headed. :-)

So back to my question, what if I, as I would like that way, have zero
and nada interest of having version control on the server side?

heimdull

unread,
Jul 15, 2009, 5:16:26 PM7/15/09
to Ruby on Rails: Talk
You can still use Capistrano to push the code from your local
directory where you are working(Like your rails root). But the main
great reason to use Capistrano is to get version deployments so that
you can roll-back if something happens to "fail" in production or
pushing to a staging environment with one tag/branch from cvs/
subversion/git then pushing the same code to production when you know
this code is good.

You can just put your own tasks in the cap scripts but this is going
to be a advanced setup. I have done something similar for a none Rails
project but it would be a custom setup for sure....

I would say that your life with Capistrano would just be SOO much
easier if you use something like git/svn...

On Jul 15, 1:46 pm, Pål Bergström <rails-mailing-l...@andreas-s.net>
wrote:

Marnen Laibow-Koser

unread,
Jul 15, 2009, 5:27:12 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
> What I like about git is
> branching.

Likewise.

> But for actual version control I can manage without it. I've
> used git for a while now and I've never needed to use it for going back
> in code. Trust me. :-)

You've never had a branch that you wanted to back out of? You've never
wanted to not deploy the bleeding-edge version of your codebase until it
stabilizes?

>
>> Getting back to the topic, do you understand now how to get Cap
>> deployment working? It's really not terribly difficult if you trust
>> Capistrano to do the right thing in most cases.
>
> Not quite. I don't think is that clear.

What don't you understand?

[...]


> And sometimes we users are just thick headed. :-)

Sure sounds like it. Give it a try and let me know if you have any
actual problems.

>
> So back to my question, what if I, as I would like that way, have zero
> and nada interest of having version control on the server side?

Then you will not get much sympathy from me, nor from many others on
this list, as you are asking for help in implementing a Certified Bad
Idea [TM]. It can be done, but I do not recommend it.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 5:34:30 PM7/15/09
to rubyonra...@googlegroups.com

> I would say that your life with Capistrano would just be SOO much
> easier if you use something like git/svn...
>

But I don't understand how. Arrgh. Should I setup a repository on the
server myself? What about my apps, what would be the path for pointers?

Sorry, but I don't think you see the issue here. How does it work on the
server side? I can't find any tutorials that talks about that. Like the
otherwise very good "The Absolute Moron's Guide to Capistrano" (that's
me). It kind of leaves out big chunk. It states "set :repository,
"http://somesvnrepository/trunk"" What about that somesvnrepository (git
in my case)?

Marnen Laibow-Koser

unread,
Jul 15, 2009, 5:42:55 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
>
>> I would say that your life with Capistrano would just be SOO much
>> easier if you use something like git/svn...
>>
>
> But I don't understand how. Arrgh. Should I setup a repository on the
> server myself?

Yes. Gitosis is a nice way to set up a Git server, or you can use a
hosted service such as Github, Unfuddle, or Gitorious.


> What about my apps, what would be the path for pointers?

Whatever you like.

>
> Sorry, but I don't think you see the issue here. How does it work on the
> server side? I can't find any tutorials that talks about that.

I think it's assumed in Cap tutorials that you already know how your
version control server works.

> Like the
> otherwise very good "The Absolute Moron's Guide to Capistrano" (that's
> me). It kind of leaves out big chunk. It states "set :repository,
> "http://somesvnrepository/trunk"" What about that somesvnrepository (git
> in my case)?

What about it? The tutorial assumes you already have your source code
repository set up. (I think most developers these days do that as one
of the very first steps in starting a new project -- I know I do.) In
any case, Cap is usually set up to communicate with an already
established repository, not to set one up itself.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 5:45:39 PM7/15/09
to rubyonra...@googlegroups.com
Marnen Laibow-Koser wrote:
> You've never had a branch that you wanted to back out of? You've never
> wanted to not deploy the bleeding-edge version of your codebase until it
> stabilizes?

No. But I might if I get into git more. But with my way of working I
know I can manage without it.

> What don't you understand?

The server side.


> Then you will not get much sympathy from me, nor from many others on
> this list, as you are asking for help in implementing a Certified Bad
> Idea [TM]. It can be done, but I do not recommend it.
>

I doubt that I'm alone on this. What really matters is getting a good
well designed and design oriented site up using solid web standards.
That comes first.

Pål Bergström

unread,
Jul 15, 2009, 5:49:16 PM7/15/09
to rubyonra...@googlegroups.com
Marnen Laibow-Koser wrote:
> Pål Bergström wrote:


>
>> What about my apps, what would be the path for pointers?
>
> Whatever you like.

That will not work. What are you talking about?

> I think most developers these days do that as one of the very first steps in starting a new project

Far from it. Are you a web developer?

Marnen Laibow-Koser

unread,
Jul 15, 2009, 5:56:46 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
> Marnen Laibow-Koser wrote:
>> Pål Bergström wrote:
>
>
>>
>>> What about my apps, what would be the path for pointers?
>>
>> Whatever you like.
>
> That will not work. What are you talking about?

Well, you can set your app's directory to anything you want. What about
that won't work?

>
>> I think most developers these days do that as one of the very first steps in starting a new project
>
> Far from it. Are you a web developer?

Yes -- 10 years' worth of one. Are you?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Pål Bergström

unread,
Jul 15, 2009, 6:02:47 PM7/15/09
to rubyonra...@googlegroups.com

>
> Yes -- 10 years' worth of one. Are you?

Yes. Longer than that. But coming from a design perspective, which
should be the focus in any serious web project.

Marnen Laibow-Koser

unread,
Jul 15, 2009, 6:23:32 PM7/15/09
to rubyonra...@googlegroups.com
Pål Bergström wrote:
>
>>
>> Yes -- 10 years' worth of one. Are you?
>
> Yes. Longer than that. But coming from a design perspective, which
> should be the focus in any serious web project.

I agree with you (I sort of started there too), but one can't neglect
good coding practice either. Making the two work together harmoniously
is what makes good Web development so challenging.

But we're losing the topic here...

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Reply all
Reply to author
Forward
0 new messages