mirror of https://github.com/zulip/zulip.git
run-dev: Use a process group to kill all spawned processes
(imported from commit 9dfddd4d9cb45c70139a167b7949bd5c4fc2791a)
This commit is contained in:
parent
23bdc74863
commit
eee951440d
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import optparse
|
import optparse
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import signal
|
||||||
import os
|
import os
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
@ -40,10 +41,13 @@ proxy_host = 'localhost:%d' % (proxy_port,)
|
||||||
|
|
||||||
os.chdir(path.join(path.dirname(__file__), '..'))
|
os.chdir(path.join(path.dirname(__file__), '..'))
|
||||||
|
|
||||||
procs = []
|
# Set up a new process group, so that we can later kill run{server,tornado}
|
||||||
|
# and all of the processes they spawn.
|
||||||
|
os.setpgrp()
|
||||||
|
|
||||||
for cmd in ['python manage.py runserver %s localhost:%d' % (manage_args, django_port),
|
for cmd in ['python manage.py runserver %s localhost:%d' % (manage_args, django_port),
|
||||||
'python manage.py runtornado %s localhost:%d' % (manage_args, tornado_port)]:
|
'python manage.py runtornado %s localhost:%d' % (manage_args, tornado_port)]:
|
||||||
procs.append(subprocess.Popen(cmd, shell=True))
|
subprocess.Popen(cmd, shell=True)
|
||||||
|
|
||||||
class Resource(resource.Resource):
|
class Resource(resource.Resource):
|
||||||
def getChild(self, name, request):
|
def getChild(self, name, request):
|
||||||
|
@ -59,5 +63,5 @@ reactor.listenTCP(proxy_port, server.Site(Resource()), interface='127.0.0.1')
|
||||||
try:
|
try:
|
||||||
reactor.run()
|
reactor.run()
|
||||||
finally:
|
finally:
|
||||||
for proc in procs:
|
# Kill everything in our process group.
|
||||||
proc.terminate()
|
os.killpg(0, signal.SIGTERM)
|
||||||
|
|
Loading…
Reference in New Issue