I've just upgraded Capistrano from v2 to v3.1.
I've re-written my tasks including one that runs a shell script that restarts NGINX among other things. To restart NGINX I have to run as sudo
which causes the error:
Sorry, you must have a TTY to run sudo
In Capistrano 2, to resolve this I added to my Capfile:
default_run_options[:pty] = true
What is the equivalent for Capistrano v3?
My deploy.rb
file looks like this:
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'APP_NAME'
namespace :deploy do
desc 'Restart NGINX'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :sudo, "./restart.sh"
end
end
end