-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-replace.py
26 lines (22 loc) · 1.01 KB
/
template-replace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# custom regexes; similar to regexesv1.py
from re import compile as re_compile
class ProcessFormatterMixin(object):
REPLACEMENTS = [(re_compile(re_str), re_str) for re_str in (
(r'/usr/lib/passenger/support-binaries/PassengerAgent'
r' temp-dir-toucher /tmp/passenger-standalone.\w+'
r' --cleanup --daemonize --pid-file'
r' /tmp/passenger-standalone.\w+/temp_dir_toucher.pid'
r' --log-file /webapps/Paldi_ReportManager/passenger.\d+.log'
r' --nginx-pid \d+'),
(r'nginx: master process'
r' /usr/lib/passenger/support-binaries/nginx-1.26.1'
r' -c /tmp/passenger-standalone.\w+/nginx.conf'
r' -p /tmp/passenger-standalone.\w+'),
)]
def adjust(self, process):
super(ProcessFormatterMixin, self).adjust(process)
for cre, re in self.REPLACEMENTS:
m = cre.match(process.cmdline)
if m and m.start() == 0 and m.end() == len(process.cmdline):
process.cmdline = re
break