To resolve this issue I needed to add set :pty, true
to my deploy.rb
file. I had to dig around a few places to find this answer so I thought i'd share incase anyone else had the same issue.
Updated deploy.rb
file
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'APP_NAME'
set :pty, true
namespace :deploy do
desc 'Restart NGINX'
task :restart do
on roles(:app), in: :sequence, wait: 1 do
execute :sudo, "./restart.sh"
end
end
end
To connect without being prompted for a password, you'll need to set up SSH key's. My production.rb
and staging.rb
look something like this:
set :stage, :production
role :app, %{ec2-000-000-000-000.eu-west-1.compute.amazonaws.com}
set :ssh_options, {
user: 'ubuntu',
keys: %w(/path/to/key/file/my_access_key.pem),
forward_agent: false
}