~jamesbeedy/charms/trusty/django-nginx/dev

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
#!/usr/bin/python3
# Copyright (c) 2016, James Beedy <jamesbeedy@gmail.com>

from charms.reactive import when
from charms.reactive import set_state
from charms.reactive import remove_state

from charmhelpers.core import unitdata
from charmhelpers.core import hookenv

from nginxlib import configure_site


config = hookenv.config()


@when('nginx.available', 'django.available')
def configure_webapp():
    hookenv.status_set('maintenance', 'Configuring Application')
    configure_site('anyapp', 'anyapp.conf')
    set_state('django.ready')
    set_state('django.restart')
    hookenv.status_set('active', 'Application available')


@when('nginx.available', 'website.available')
def configure_website(website):
    website.configure(port=config['port'])