blob: 56542bf0849317a7b0153347b88f2ab55e0a8b56 [file] [log] [blame]
Tony Mack71592a52013-03-28 20:17:47 -04001#!/usr/bin/env python
2import os
3import sys
Tony Mack745bf6e2013-04-17 11:06:35 -04004import threading
Tony Mack71592a52013-03-28 20:17:47 -04005
6from plstackapi.planetstack.config import Config
Tony Mack704c1b02013-04-17 10:45:45 -04007from plstackapi.openstack.sliveragent import SliverAgent
Tony Mackcd6bf662013-04-30 18:20:27 -04008from plstackapi.openstack.siteagent import SiteAgent
Tony Mack71592a52013-03-28 20:17:47 -04009
10if __name__ == '__main__':
11
Tony Mackcd6bf662013-04-30 18:20:27 -040012 # bootstrap envirnment
Tony Mack71592a52013-03-28 20:17:47 -040013 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "plstackapi.planetstack.settings")
14 from django.core.management import ManagementUtility
15 config = Config()
Tony Macke02d7202013-03-29 11:23:56 -040016 url = "%s:%s" % (config.api_host, config.api_port)
Tony Mack71592a52013-03-28 20:17:47 -040017 args = [__file__, 'runserver', url]
Tony Mackcd6bf662013-04-30 18:20:27 -040018
19 # run site agent once on startup
20 SiteAgent().run()
21
22 # start the sliver agent thread
Tony Mack704c1b02013-04-17 10:45:45 -040023 sliver_agent = SliverAgent()
Tony Mack745bf6e2013-04-17 11:06:35 -040024 sliver_agent_thread = threading.Thread(target=sliver_agent.run)
25 sliver_agent_thread.start()
Tony Mackcd6bf662013-04-30 18:20:27 -040026
27 # start the server
28 server = ManagementUtility(args)
Tony Mack745bf6e2013-04-17 11:06:35 -040029 server.execute()