blob: 2ed2b287a3a2e0257cc06b5907a705f6ba010ef5 [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
Tony Mack2ff86222013-05-10 16:54:14 -04006os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings")
Siobhan Tully30fd4292013-05-10 08:59:56 -04007from planetstack.config import Config
8from openstack.sliveragent import SliverAgent
9from openstack.siteagent import SiteAgent
Tony Mack71592a52013-03-28 20:17:47 -040010
11if __name__ == '__main__':
12
Tony Mackcd6bf662013-04-30 18:20:27 -040013 # bootstrap envirnment
Tony Mack71592a52013-03-28 20:17:47 -040014 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()