forked from code-dot-org/code-dot-org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflush_cache
More file actions
executable file
·32 lines (25 loc) · 886 Bytes
/
Copy pathflush_cache
File metadata and controls
executable file
·32 lines (25 loc) · 886 Bytes
1
2
3
4
5
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
32
#!/usr/bin/env ruby
require_relative '../deployment'
require 'cdo/rake_utils'
require 'cdo/aws/cloudfront'
require 'sshkit'
SSHKit::Backend::Netssh.configure {|ssh| ssh.ssh_options = {paranoid: false}}
unless CDO.daemon
CDO.log.error 'This script must be run on daemon'
exit 1
end
if system 'systemctl is-active --quiet varnish'
varnish_ban_cmd = "sudo varnishadm -T localhost:6082 -S /etc/varnish/secret 'ban obj.status ~ .'"
CDO.log.info 'Flushing Varnish cache on daemon...'
RakeUtils.system varnish_ban_cmd
app_servers = CDO.app_servers.values
unless app_servers.empty?
CDO.log.info 'Flushing Varnish caches on frontends...'
SSHKit::Coordinator.new(app_servers).each do
execute varnish_ban_cmd, raise_on_non_zero_exit: false
end
end
end
CDO.log.info 'Flushing CloudFront caches...'
AWS::CloudFront.invalidate_caches
CDO.log.info 'All done!'