Magic Hat of TYPO3
Magic Hat of TYPO3

Reputation: 23

capistrano 3.8, shared_path seems partly be ignored

I'm working on a capistrano deployment configuration and would like to set the shared folder on another place. Background is, that I want to use a wildcard deployment (review app) and the target directory will be generated on-the-fly (which means, there isn't a shared folder in it) and I would use the shared folder with the assets across ALL review apps in this environment.

Therefore I have directories on the server:

/var/www/review/application_name

/var/www/review/application_name/shared/... (here are the assets and configurations I would like to share across ALL review apps)

/var/www/review/application_name/branch-name/ - this is the deployment path which will be created by capistrano when deploying a specific branch to the review stage.

I have used shared_path

set :shared_path, "/var/www/review/#{fetch(:application)}"

which works fine for the linked_dirs, but NOT for the linked_files. I get the error message:

00:01 deploy:check:linked_files
  ERROR linked file /var/www/review/www.app.tld/123/shared/myfile does not exist on review.app.tld

which is true - but I don't know how to tell cap to put it in place. Of course the named file is in the shared folder

/var/www/review/www.app.tld/shared/

but capistrano seems to search on the wrong place when trying to check the linked_files (again: the linked_dirs are processed correct).

Any hints? Thanks in advance!

Upvotes: 0

Views: 491

Answers (2)

Matt Brictson
Matt Brictson

Reputation: 11102

The shared_path is not something you can configure directly. Using set will not have any effect.

The shared path in Capistrano is always a directory named shared inside your :deploy_to location. Therefore if you want to change the shared path, you must set :deploy_to, like so:

set :deploy_to, -> { "/var/www/review/#{fetch(:application)}" }

This will effectively cause shared_path to become:

"/var/www/review/#{fetch(:application)}/shared"

Keep in mind that :deploy_to is used as the base directory for many things: releases, repo, current, etc. So if you change :deploy_to you will affect all of them.

Upvotes: 1

tadman
tadman

Reputation: 211680

If your :application variable is defined at some later point, or changed, you'll need to set to a deferred variable:

set :shared_path, -> { "/var/www/review/#{fetch(:application)}" }

This evaluates that string on-demand instead of in advance.

Upvotes: 0

Related Questions