Permalink
Browse files

departed

  • Loading branch information...
1 parent b7cb940 commit b8a79ee345b95caadfb19539f7fb349a11aa1619 @mmm committed Nov 28, 2011
Showing with 29 additions and 2 deletions.
  1. +1 −2 README.markdown
  2. +28 −0 hooks/reverseproxy-relation-departed
View
@@ -1,8 +1,6 @@
# TODO
-- reverseproxy-relation-departed
- - same as changed?
- config
- external port
- cache size
@@ -11,6 +9,7 @@
- charm-tools
- tests
- gemify
+ - exceptions for config files
- not restarting on ec2, but working fine on lxc
# Varnish
@@ -0,0 +1,28 @@
+#!/usr/bin/ruby -w
+
+require 'lib/charm-tools'
+
+log "backend relation departed"
+
+def safe_remote_unit_name
+ ENV['JUJU_REMOTE_UNIT'].gsub(/\//, "_")
+end
+
+def active_backends
+ backends = local_config_get(:active_backends) || {}
+ backends.delete(safe_remote_unit_name) # maybe also check the full `relation-list`?
+ local_config_set({ :active_backends => backends })
+ backends
+end
+
+def update_varnish_config
+ log "Writing varnish config"
+ config_file = '/etc/varnish/default.vcl'
+ File.rename(config_file,"#{config_file}.dist") if File.exists?(config_file)
+ expand_template_to_file( 'default.vcl.erb', config_file )
+end
+update_varnish_config
+
+log "Restart Varnish"
+restart_service "varnish"
+

0 comments on commit b8a79ee

Please sign in to comment.