diff options
author | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-12-21 16:36:29 +0200 |
---|---|---|
committer | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-12-21 16:36:29 +0200 |
commit | c77174ade8d36f377cfa74da4c487f04988a9679 (patch) | |
tree | 1d5e4de466b4a4445e59a163d7376a7c7d7faf2c /scripts/scapy_daemon_server | |
parent | fff19c8c2faced0972601ca9956bb36a33aa6e87 (diff) |
Add affinity for scapy_daemon_server to master thread from config file
Change-Id: I83d3138b713f3448bbc649e6d7a5fabe3860285c
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/scapy_daemon_server')
-rwxr-xr-x | scripts/scapy_daemon_server | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/scripts/scapy_daemon_server b/scripts/scapy_daemon_server index 99f8a6ac..a5e4df06 100755 --- a/scripts/scapy_daemon_server +++ b/scripts/scapy_daemon_server @@ -73,7 +73,7 @@ def run_command(command, timeout = 15, poll_rate = 0.1, cwd = None): def get_daemon_pid(): pid = None for conn in netstat.netstat(): - if conn[2] == '0.0.0.0' and int(conn[3]) == args.daemon_port and conn[6] == 'LISTEN': + if conn[2] == '0.0.0.0' and int(conn[3]) == args.port and conn[6] == 'LISTEN': pid = conn[7] if pid is None: raise Exception('Found the connection, but could not determine pid: %s' % conn) @@ -84,7 +84,7 @@ def get_daemon_pid(): # faster variant of get_daemon_pid def is_running(): for conn in netstat.netstat(with_pid = False): - if conn[2] == '0.0.0.0' and int(conn[3]) == args.daemon_port and conn[6] == 'LISTEN': + if conn[2] == '0.0.0.0' and int(conn[3]) == args.port and conn[6] == 'LISTEN': return True return False @@ -102,8 +102,8 @@ def start_daemon(): return server_path = os.path.join(pwd, 'automation', 'trex_control_plane', 'stl', 'services', 'scapy_server') with tempfile.TemporaryFile() as stdout_file: - subprocess.Popen(shlex.split("su -s /bin/bash -c '%s scapy_zmq_server.py -s %s' nobody" % (sys.executable, args.daemon_port)), stdout = stdout_file, - stderr = subprocess.STDOUT, cwd = server_path, close_fds = True, universal_newlines = True) + subprocess.Popen(shlex.split("taskset -c %s su -s /bin/bash -c '%s scapy_zmq_server.py -s %s' nobody" % (args.core, sys.executable, args.port)), + stdout = stdout_file, stderr = subprocess.STDOUT, cwd = server_path, close_fds = True, universal_newlines = True) ret = progress(is_running, 'Starting Scapy server', 'Scapy server is started', 'Scapy server failed to run') if ret: stdout_file.seek(0) @@ -151,10 +151,10 @@ if __name__ == '__main__': formatter_class = RawTextHelpFormatter, ) - parser.add_argument('-p', '--port', type = int, default = 4507, metavar = 'PORT', dest = 'daemon_port', + parser.add_argument('-p', '--port', type = int, default = 4507, help='Select tcp port on which Scapy server will listen.\nDefault is 4507.') - #parser.add_argument('-c', '--core', type = int, default = 0, - # help='Core number to set affinity.\nAdvised to set on free core or TRex master thread core\nDefault is 0.') + parser.add_argument('-c', '--core', type = int, default = 0, + help='Core number to set affinity.\nAdvised to set on free core or TRex master thread core\nDefault is 0.') parser.add_argument('action', choices=action_funcs.keys(), action='store', help=actions_help) parser.usage = None |