forked from tsuru/mysqlapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wsgi.py
37 lines (24 loc) · 842 Bytes
/
wsgi.py
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
33
34
35
36
37
# -*- coding: utf-8 -*-
# Copyright 2013 mysqlapi authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
import os
import signal
import crane_ec2
from mysqlapi.api import creator
from mysqlapi.api.models import DatabaseManager, Instance
os.environ["DJANGO_SETTINGS_MODULE"] = "mysqlapi.settings"
def huphandler(signum, frame):
creator.reset_queue()
def termhandler(signum, frame):
creator.close_queue()
def start():
client = crane_ec2.Client()
signal.signal(signal.SIGHUP, huphandler)
signal.signal(signal.SIGTERM, termhandler)
creator.set_model(Instance)
creator.build_queue()
creator.start_creator(DatabaseManager, client)
start()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()