Commit 18fd296a authored by Nicolas Delaby's avatar Nicolas Delaby

Stop daemon smoothly, and insure that all sub-processes will be terminated.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42106 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b7733e92
...@@ -8,6 +8,8 @@ from cloudooo.handler.ooo.utils.utils import socketStatus ...@@ -8,6 +8,8 @@ from cloudooo.handler.ooo.utils.utils import socketStatus
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
from os import chdir, path, environ, curdir from os import chdir, path, environ, curdir
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import tempfile
import os
ENVIRONMENT_PATH = path.abspath(path.dirname(__file__)) ENVIRONMENT_PATH = path.abspath(path.dirname(__file__))
...@@ -83,18 +85,21 @@ def run(): ...@@ -83,18 +85,21 @@ def run():
suite.addTest(module.test_suite()) suite.addTest(module.test_suite())
if DAEMON: if DAEMON:
command = [paster_path, "serve", server_cloudooo_conf] fd, pid_filename = tempfile.mkstemp()
process = Popen(command, stdout=PIPE, stderr=PIPE) command = [paster_path, "serve", '--daemon', '--pid-file', pid_filename,
server_cloudooo_conf]
process = Popen(command)
wait_use_port(hostname, openoffice_port) wait_use_port(hostname, openoffice_port)
wait_use_port(hostname, server_port) wait_use_port(hostname, server_port)
chdir(ENVIRONMENT_PATH) chdir(ENVIRONMENT_PATH)
try: try:
TestRunner(verbosity=2).run(suite) TestRunner(verbosity=2).run(suite)
finally: finally:
process.send_signal(1) command = [paster_path, 'serve', '--stop-daemon', '--pid-file',
wait_liberate_port(hostname, server_port) pid_filename]
process.terminate() stop_process = Popen(command)
wait_liberate_port(hostname, server_port) stop_process.communicate()
# pid file is destroyed by paster
elif OPENOFFICE: elif OPENOFFICE:
chdir(ENVIRONMENT_PATH) chdir(ENVIRONMENT_PATH)
openoffice, xvfb = startFakeEnvironment(conf_path=server_cloudooo_conf) openoffice, xvfb = startFakeEnvironment(conf_path=server_cloudooo_conf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment