blob: 41de4976f1cd8af8454dfc77bdccb3e3cc0aa914 [file] [log] [blame]
Chris Matthews4d39f842017-08-17 20:26:33 +00001#!/usr/bin/python
2"""
3Kill all the Zombie Gunicon processes.
4
5"""
6import re
7import subprocess
8
9out = subprocess.check_output(["ps", "auxxxf"])
10
11stranded = re.compile(r"^lnt\s+(?P<pid>\d+).*00\sgunicorn:\swork")
12pids = []
13for line in out.split('\n'):
14 m = stranded.match(line)
15 if m:
16 pid = m.groupdict()['pid']
17 pids.append(pid)
18 else:
19 print ">", line
20
21if not pids:
22 print "No PIDs to kill."
23
24for pid in pids:
25 print subprocess.check_output(["kill", "-9", "{}".format(pid)])