mirror of https://gitlab.com/ita1024/waf.git
Cleanup in the prefork scripts
This commit is contained in:
parent
d9908f38ef
commit
0bf605e194
|
@ -111,7 +111,7 @@ public class Prefork implements Runnable, Comparator<Object[]> {
|
|||
public String make_out(Socket sock, String stdout, String stderr, String exc) {
|
||||
if ((stdout == null || stdout.length() == 0) && (stderr == null || stderr.length() == 0) && (exc == null || exc.length() == 0))
|
||||
{
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
JsonArray ret = new JsonArray();
|
||||
|
@ -201,9 +201,11 @@ public class Prefork implements Runnable, Comparator<Object[]> {
|
|||
String msg = make_out(sock, stdout, stderr, exc);
|
||||
|
||||
// RES, status, ret size
|
||||
String ret = String.format("%-64s", String.format("RES,%d,%d", status, msg.length()));
|
||||
int len = msg != null ? msg.length() : 0;
|
||||
|
||||
String ret = String.format("%-64s", String.format("RES,%d,%d", status, len));
|
||||
out.write(ret.getBytes());
|
||||
if (msg.length() > 0)
|
||||
if (len > 0)
|
||||
{
|
||||
out.write(msg.getBytes());
|
||||
}
|
||||
|
|
|
@ -356,6 +356,18 @@ else:
|
|||
raise ValueError('Could not start the server!')
|
||||
CONNS.append(conn)
|
||||
|
||||
def init_smp(self):
|
||||
if not self.smp:
|
||||
return
|
||||
if Utils.unversioned_sys_platform() in ('freebsd',):
|
||||
pid = os.getpid()
|
||||
cmd = ['cpuset', '-l', '0', str(pid)]
|
||||
elif Utils.unversioned_sys_platform() in ('linux',):
|
||||
pid = os.getpid()
|
||||
cmd = ['taskset', '-pc', '0', str(pid)]
|
||||
if cmd:
|
||||
self.cmd_and_log(cmd, quiet=0)
|
||||
|
||||
def options(opt):
|
||||
init_key(opt)
|
||||
init_servers(opt, 40)
|
||||
|
@ -366,6 +378,7 @@ else:
|
|||
|
||||
init_key(bld)
|
||||
init_servers(bld, bld.jobs)
|
||||
init_smp(bld)
|
||||
|
||||
bld.__class__.exec_command_old = bld.__class__.exec_command
|
||||
bld.__class__.exec_command = exec_command
|
||||
|
|
|
@ -14,7 +14,6 @@ except ImportError:
|
|||
|
||||
import json as pickle
|
||||
|
||||
DEFAULT_PORT = 51200
|
||||
SHARED_KEY = None
|
||||
HEADER_SIZE = 64
|
||||
|
||||
|
@ -53,13 +52,19 @@ if 1:
|
|||
return pool
|
||||
Runner.Parallel.init_task_pool = init_task_pool
|
||||
|
||||
PORT = 51200
|
||||
|
||||
def make_server(bld, idx):
|
||||
wd = os.path.dirname(os.path.abspath('__file__'))
|
||||
port = PORT + idx
|
||||
cmd = "java -cp %s/minimal-json-0.9.3-SNAPSHOT.jar:. Prefork %d" % (wd, PORT)
|
||||
proc = subprocess.Popen(cmd.split(), shell=False, cwd=wd)
|
||||
top = getattr(bld, 'preforkjava_top', os.path.dirname(os.path.abspath('__file__')))
|
||||
cp = getattr(bld, 'preforkjava_cp', os.path.join(top, 'minimal-json-0.9.3-SNAPSHOT.jar') + os.pathsep + top)
|
||||
|
||||
for x in cp.split(os.pathsep):
|
||||
if x and not os.path.exists(x):
|
||||
Logs.warn('Invalid classpath: %r' % cp)
|
||||
Logs.warn('Set for example bld.preforkjava_cp to /path/to/minimal-json:/path/to/Prefork.class/')
|
||||
|
||||
cwd = getattr(bld, 'preforkjava_cwd', top)
|
||||
port = getattr(bld, 'preforkjava_port', 51200)
|
||||
cmd = getattr(bld, 'preforkjava_cmd', 'java -cp %s%s Prefork %d' % (cp, os.pathsep, port))
|
||||
proc = subprocess.Popen(cmd.split(), shell=False, cwd=cwd)
|
||||
proc.port = port
|
||||
return proc
|
||||
|
||||
|
@ -203,6 +208,18 @@ if 1:
|
|||
raise ValueError('Could not start the server!')
|
||||
CONNS.append(conn)
|
||||
|
||||
def init_smp(self):
|
||||
if not self.smp:
|
||||
return
|
||||
if Utils.unversioned_sys_platform() in ('freebsd',):
|
||||
pid = os.getpid()
|
||||
cmd = ['cpuset', '-l', '0', str(pid)]
|
||||
elif Utils.unversioned_sys_platform() in ('linux',):
|
||||
pid = os.getpid()
|
||||
cmd = ['taskset', '-pc', '0', str(pid)]
|
||||
if cmd:
|
||||
self.cmd_and_log(cmd, quiet=0)
|
||||
|
||||
def options(opt):
|
||||
init_key(opt)
|
||||
init_servers(opt, 40)
|
||||
|
@ -213,6 +230,7 @@ if 1:
|
|||
|
||||
init_key(bld)
|
||||
init_servers(bld, bld.jobs)
|
||||
init_smp(bld)
|
||||
|
||||
bld.__class__.exec_command_old = bld.__class__.exec_command
|
||||
bld.__class__.exec_command = exec_command
|
|
@ -272,6 +272,18 @@ if 1:
|
|||
SERVERS.append(pid)
|
||||
CONNS.append(conn)
|
||||
|
||||
def init_smp(self):
|
||||
if not self.smp:
|
||||
return
|
||||
if Utils.unversioned_sys_platform() in ('freebsd',):
|
||||
pid = os.getpid()
|
||||
cmd = ['cpuset', '-l', '0', str(pid)]
|
||||
elif Utils.unversioned_sys_platform() in ('linux',):
|
||||
pid = os.getpid()
|
||||
cmd = ['taskset', '-pc', '0', str(pid)]
|
||||
if cmd:
|
||||
self.cmd_and_log(cmd, quiet=0)
|
||||
|
||||
def build(bld):
|
||||
if bld.cmd == 'clean':
|
||||
return
|
||||
|
@ -279,6 +291,7 @@ if 1:
|
|||
(pid, conn) = make_conn(bld)
|
||||
SERVERS.append(pid)
|
||||
CONNS.append(conn)
|
||||
init_smp(bld)
|
||||
bld.__class__.exec_command_old = bld.__class__.exec_command
|
||||
bld.__class__.exec_command = exec_command
|
||||
|
||||
|
|
Loading…
Reference in New Issue