6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/chinook/capistrano/ping.rb', line 6
def self.load_into(configuration)
configuration.load do
namespace :chinook do
desc 'Sends a basic curl request to the website to wake it up.'
task :ping, except: { no_release: true } do
unless exists?(:ping_url)
logger.info 'Cannot ping website without :ping_url defined. Skipping task.'
next
end
rails_env = fetch(:rails_env, 'production')
destination = fetch(:ping_url)
ping_command = "curl -LI #{destination}"
logger.info "Pinging website to wake it up at #{destination}"
if configuration.dry_run
logger.info "DRY RUN: Ping not sent."
else
result = ""
run(ping_command, once: true) { |ch, stream, data| result << data }
end
logger.info "Ping sent; site should now be awake and responsive."
end
end
end
end
|