Skip to content

Instantly share code, notes, and snippets.

@bcsaller
Created May 6, 2015 19:01
Show Gist options
  • Save bcsaller/788da7aee582f5dff659 to your computer and use it in GitHub Desktop.
Save bcsaller/788da7aee582f5dff659 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from charmhelpers.core import when, when_not
import framework
import helpers
CONFIG_FILE = "/etc/myapp/app.conf"
@when("db.connectable", "cache.ready")
def regen_config(db, cache):
data = {"dsn": db.dsn, "cache_url": dict(cache)}
helpers.generate_template(CONFIG_FILE, "templates/app.config.j2", data)
helpers.restart_service("myapp")
@when_not("db.connectable", "cache.ready")
def shutdown_service():
helpers.shutdown_service("myapp")
if __name__ == '__main__':
framework.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment