Remove sleep hack on startup, move so portal always starts before server.

This commit is contained in:
Stephen Hansen 2013-01-31 15:40:20 -08:00
parent 5cfff771f2
commit 9d0baa2d5c

View file

@ -160,19 +160,7 @@ def start_services(server_argv, portal_argv):
return
queue.put(("portal_stopped", rc)) # this signals the controller that the program finished
try:
if server_argv:
# start server as a reloadable thread
SERVER = thread.start_new_thread(server_waiter, (processes, ))
except IOError, e:
print "Server IOError: %s\nA possible explanation for this is that 'twistd' is not found." % e
return
if portal_argv:
if is_pypy:
# This is a hack; without it, the *server* stalls out and never finishes loading under PyPy.
time.sleep(1)
try:
if get_restart_mode(PORTAL_RESTART) == "True":
# start portal as interactive, reloadable thread
@ -180,13 +168,19 @@ def start_services(server_argv, portal_argv):
else:
# normal operation: start portal as a daemon; we don't care to monitor it for restart
PORTAL = Popen(portal_argv)
if not SERVER:
# if portal is daemon and no server is running, we have no reason to continue to the loop.
return
except IOError, e:
print "Portal IOError: %s\nA possible explanation for this is that 'twistd' is not found." % e
return
try:
if server_argv:
# start server as a reloadable thread
SERVER = thread.start_new_thread(server_waiter, (processes, ))
except IOError, e:
print "Server IOError: %s\nA possible explanation for this is that 'twistd' is not found." % e
return
# Reload loop
while True: