I know that I can get the location of my rails app with Rails.root
:
> Rails.root
=> #<Pathname:/var/www/app-name/releases/20150507181426>
I am looking for the function to call to get capistrano's shared folder, which in this case is found here:
/var/www/app-name/shared/
I need to be able to get the path from within ruby code. Thanks in advance.
You really shouldn't need to know what Capistrano's shared path is. During the deployment process it's expected that you'll create links to any directories that are shared between deployments.
The linked_dirs
variable defines this:
set :linked_dirs, %w[ example ]
If set, during deployment releases/NNN/example
will be linked to shared/example
. You can add or alter this list as required.
Update:
If you're concerned about this symlink being removed as subsequent deployments are applied, it's worthwhile to expand this link to the full path by whatever process uses it before exercising that.
Following these links is the most reliable way to get to the proper destination.
You can simply use the global capistrano variable shared_path
(works on capistrano v2 and v3).
It provide you the base path of your shared stuff:
puts "#{shared_path}"
=> /DEPLOY_PATH/APP_NAME/shared
A list of possible useful global variables can be found here, I guess that most of them work well in capistrano v3 too.
UPDATE
Just note that most of them are only available under the capistrano libs (deploy.rb
or the custom stages: development.rb
,staging.rb
, production.rb
,...) or in the capistrano rake tasks (when using for example the on role(:app) do {...}
callback).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With