# Multiple deploy scripts

**URL:** <https://www.ruby-forum.com/t/multiple-deploy-scripts/140800>\
**Category:** Deployment\
**Created:** [June 18, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/multiple-deploy-scripts/140800 "2008-06-18T17:50:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f17d59/32.png) [@Slant](https://www.ruby-forum.com/u/Slant)\
**Post date:** [June 18, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/multiple-deploy-scripts/140800/1 "2008-06-18T17:50:12Z")

</div>

I’m taking over a project and am wanting to put a staging server in  
place.

The thing holding me up is the Capistrano deploy scripts. I have  
changed the ‘deploy.rb’ file to ‘deploy-production.rb’ and then added  
a ‘deploy-stage.rb’ file.

Here is where I believe my problem is coming into play:  
The current contents of my ‘Capfile’:

load ‘deploy’ if respond\_to?(:namespace) # cap2 differentiator  
Dir[‘vendor/plugins/_/recipes/_.rb’].each { |plugin| load(plugin) }  
load ‘config/deploy-stage’  
load ‘config/deploy-production’

This was a shot in the dark (adding the last two lines). Am I  
misunderstanding what that load line does? Here’s is why I’m  
confused. After modifying the file as such, I then go to the command  
line and attempt to run the stage script with ‘cap -f config/deploy-  
stage.rb deploy’. I then receive a lovely message telling me that  
“the task `deploy’ does not exist”. Whaaa? Well, we know it does, so  
this must be caused by the Capfile no longer being included. I  
thought I read in the documentation that if ‘-f’ is used even once, it  
will negate the Capfile’s inclusion.

So I suppose I’m looking for some direction here. A seemingly ideal  
solution would be to create a task such as ‘cap deploy:stage’ and ‘cap  
deploy:production’ in order to deploy to stage. Is this a bad idea?  
How would I go about doing this?

Thank you!!!

---

<div class="post-metadata">

**Author:** ![Slant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f17d59/32.png) [@Slant](https://www.ruby-forum.com/u/Slant)\
**Post date:** [June 18, 2008, 6:51pm UTC](https://www.ruby-forum.com/t/multiple-deploy-scripts/140800/2 "2008-06-18T18:51:39Z")

</div>

On Wed, Jun 18, 2008 at 8:49 AM, Slant [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> “the task `deploy’ does not exist”. Whaaa? Well, we know it does, so  
> this must be caused by the Capfile no longer being included. I  
> thought I read in the documentation that if ‘-f’ is used even once, it  
> will negate the Capfile’s inclusion.
> 
> So I suppose I’m looking for some direction here. A seemingly ideal  
> solution would be to create a task such as ‘cap deploy:stage’ and ‘cap  
> deploy:production’ in order to deploy to stage. Is this a bad idea?  
> How would I go about doing this?

My understanding is that calling:

RAILS\_ENV=‘staging’ && cap deploy

should do it. Maintaining two versions of basically the same file goes  
against the DRY principle.

–  
Anthony E.  
408-656-2473  
[http://anthony.ettinger.name](http://anthony.ettinger.name)

---

<div class="post-metadata">

**Author:** ![Slant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f17d59/32.png) [@Slant](https://www.ruby-forum.com/u/Slant)\
**Post date:** [June 18, 2008, 7:10pm UTC](https://www.ruby-forum.com/t/multiple-deploy-scripts/140800/3 "2008-06-18T19:10:00Z")

</div>

On Wed, Jun 18, 2008 at 5:49 PM, Slant [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> “the task `deploy’ does not exist”. Whaaa? Well, we know it does, so  
> this must be caused by the Capfile no longer being included. I  
> thought I read in the documentation that if ‘-f’ is used even once, it  
> will negate the Capfile’s inclusion.
> 
> So I suppose I’m looking for some direction here. A seemingly ideal  
> solution would be to create a task such as ‘cap deploy:stage’ and ‘cap  
> deploy:production’ in order to deploy to stage. Is this a bad idea?  
> How would I go about doing this?
> 
> Thank you!!!

I did go in a different direction:

Top of my config/deploy.rb file try loads recipes from  
config/deploy/\*.rb, each of these “sub recipes” only created a task  
for production and staging, that define db, app and web roles, also  
rails\_env

So I can do in the command line:

cap production deploy

cap staging deploy

etc.

Learned that trick from some EY recipes 😉

## Regards,

## Luis L. AREA 17

Human beings, who are almost unique in having the ability to learn from  
the experience of others, are also remarkable for their apparent  
disinclination to do so.  
Douglas Adams

---

<div class="post-metadata">

**Author:** ![Slant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f17d59/32.png) [@Slant](https://www.ruby-forum.com/u/Slant)\
**Post date:** [June 19, 2008, 4:05am UTC](https://www.ruby-forum.com/t/multiple-deploy-scripts/140800/4 "2008-06-19T04:05:36Z")

</div>

On Wed, 2008-06-18 at 19:09 +0200, Luis L. wrote:

> cap staging deploy
> 
> etc.
> 
> Learned that trick from some EY recipes 😉

Right on, yup, this is capistrano “multistage” and is included in the  
capistrano-ext gem:

[http://quotedprintable.com/2007/7/23/capistrano-multi-stage-support](http://quotedprintable.com/2007/7/23/capistrano-multi-stage-support)

Great stuff, very handy.

Yours,

tom

---

<div class="post-metadata">

**Author:** ![Slant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f17d59/32.png) [@Slant](https://www.ruby-forum.com/u/Slant)\
**Post date:** [June 19, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/multiple-deploy-scripts/140800/5 "2008-06-19T23:35:19Z")

</div>

Superb!! Thank you all so very much. I was not aware of the  
multistage feature!! Crazy…
