Show More
@@ -105,9 +105,10 b' class AdminProcessManagementView(BaseApp' | |||||
105 | def process_management_signal(self): |
|
105 | def process_management_signal(self): | |
106 | pids = self.request.json.get('pids', []) |
|
106 | pids = self.request.json.get('pids', []) | |
107 | result = [] |
|
107 | result = [] | |
|
108 | ||||
108 | def on_terminate(proc): |
|
109 | def on_terminate(proc): | |
109 | msg = "process `PID:{}` terminated with exit code {}".format( |
|
110 | msg = "process `PID:{}` terminated with exit code {}".format( | |
110 | proc.pid, proc.returncode) |
|
111 | proc.pid, proc.returncode or 0) | |
111 | result.append(msg) |
|
112 | result.append(msg) | |
112 |
|
113 | |||
113 | procs = [] |
|
114 | procs = [] | |
@@ -121,15 +122,22 b' class AdminProcessManagementView(BaseApp' | |||||
121 |
|
122 | |||
122 | children = proc.children(recursive=True) |
|
123 | children = proc.children(recursive=True) | |
123 | if children: |
|
124 | if children: | |
124 |
|
|
125 | log.warning('Wont kill Master Process') | |
125 | else: |
|
126 | else: | |
126 | procs.append(proc) |
|
127 | procs.append(proc) | |
127 |
|
128 | |||
128 | for p in procs: |
|
129 | for p in procs: | |
129 |
|
|
130 | try: | |
|
131 | p.terminate() | |||
|
132 | except psutil.AccessDenied as e: | |||
|
133 | log.warning('Access denied: {}'.format(e)) | |||
|
134 | ||||
130 | gone, alive = psutil.wait_procs(procs, timeout=10, callback=on_terminate) |
|
135 | gone, alive = psutil.wait_procs(procs, timeout=10, callback=on_terminate) | |
131 | for p in alive: |
|
136 | for p in alive: | |
132 |
|
|
137 | try: | |
|
138 | p.kill() | |||
|
139 | except psutil.AccessDenied as e: | |||
|
140 | log.warning('Access denied: {}'.format(e)) | |||
133 |
|
141 | |||
134 | return {'result': result} |
|
142 | return {'result': result} | |
135 |
|
143 |
General Comments 0
You need to be logged in to leave comments.
Login now