add log for rpc server

Change-Id: I94bf597d3da4a3876290c4a9eab9948432d98044
This commit is contained in:
Kun Huang 2015-11-13 21:58:18 +08:00
parent 001f2bb93c
commit 7a778c5bff
2 changed files with 6 additions and 1 deletions

View File

@ -32,6 +32,7 @@ class TraceEndpoint(object):
pids = []
for tr in tracers:
pid = run_agent(task.uuid, tr)
print "[LOG] saving pid %s" % pid
pids.append(pid)
task = db_api.task_update(task.uuid, pids=pids)
@ -47,6 +48,7 @@ class TaskEndpoint(object):
print "[LOG] stopping task: %s" % uuid
task = db_api.task_get(uuid)
for pid in task.pids:
print "[LOG] interupt process %s" % pid
p = psutil.Process(int(pid))
p.send_signal(signal.SIGINT)

View File

@ -29,6 +29,7 @@ def read_from_ag(ag):
def main():
task_uuid, ag = sys.argv[1], sys.argv[2]
cmd = read_from_ag(ag)
print "[LOG] running CMD: %s" % cmd
worker = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
out = []
@ -40,7 +41,7 @@ def main():
_t = (time.time(), t.strip())
out.append(_t)
except KeyboardInterrupt:
pass
print "[LOG] %s is interupted" % ag
# psutil is much more professional... I have to use it instead
# this kill is to script process
@ -59,7 +60,9 @@ def main():
results = copy(task.results)
for ret in parse_func(out):
ret = db_api.result_create(**ret)
print "[LOG] appending result with id %s" % ret.uuid
results.append(ret.uuid)
print "[LOG] update tas with result %s" % task_uuid
db_api.task_update(task_uuid, results=results)
time.sleep(2)
co.stop()