File: deploy.rb

# deploy.rb

Path: | lib/capistrano/recipes/deploy.rb
Last Update: | Thu Nov 30 10:32:32 +0000 2023

### Required files

benchmark yaml capistrano/recipes/deploy/scm capistrano/recipes/deploy/strategy erb

### Methods

_cset depend run_locally try_runner try_sudo with_env

### Public Instance methods

_cset(name, *args, &block)
depend(location, type, *args)

Auxiliary helper method for the `deploy:check’ task. Lets you set up your own dependencies.

run_locally(cmd)

logs the command then executes it locally. returns the command output as a string

try_runner(*args)

Same as sudo, but tries sudo with :as set to the value of the :runner variable (which defaults to "app").

try_sudo(*args)

If a command is given, this will try to execute the given command, as described below. Otherwise, it will return a string for use in embedding in another command, for executing that command as described below.

If :run_method is :sudo (or :use_sudo is true), this executes the given command via `sudo`. Otherwise is uses `run`. If :as is given as a key, it will be passed as the user to sudo as, if using sudo. If the :as key is not given, it will default to whatever the value of the :admin_runner variable is, which (by default) is unset.

THUS, if you want to try to run something via sudo, and what to use the root user, you‘d just to try_sudo(‘something’). If you wanted to try_sudo as someone else, you‘d just do try_sudo(‘something’, :as => "bob"). If you always wanted sudo to run as a particular user, you could do set(:admin_runner, "bob").

with_env(name, value) {|| ...}

Temporarily sets an environment variable, yields to a block, and restores the value when it is done.

[Validate]