mirror of
https://github.com/CopterExpress/clover.git
synced 2026-06-10 03:24:32 +00:00
clever.service: pipe all errors to /tmp/clever.err (#176)
* clever.service: pipe all errors to /tmp/clever.err * clever.service: run with Bash * selfcheck: parse node errors and group them
This commit is contained in:
@@ -5,8 +5,9 @@ After=network.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=pi
|
User=pi
|
||||||
ExecStart=/bin/sh -c ". /home/pi/catkin_ws/devel/setup.sh; \
|
ExecStart=/bin/bash -c ". /home/pi/catkin_ws/devel/setup.sh; \
|
||||||
ROS_HOSTNAME=`hostname`.local exec roslaunch clever clever.launch --wait --screen --skip-log-check"
|
ROS_HOSTNAME=`hostname`.local exec roslaunch clever clever.launch --wait --screen --skip-log-check \
|
||||||
|
2> >(tee /tmp/clever.err)"
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ espeak espeak-data python-espeak \
|
|||||||
ntpdate \
|
ntpdate \
|
||||||
python-dev \
|
python-dev \
|
||||||
python3-dev \
|
python3-dev \
|
||||||
python-systemd \
|
|
||||||
mjpg-streamer=2.0 \
|
mjpg-streamer=2.0 \
|
||||||
&& echo_stamp "Everything was installed!" "SUCCESS" \
|
&& echo_stamp "Everything was installed!" "SUCCESS" \
|
||||||
|| (echo_stamp "Some packages wasn't installed!" "ERROR"; exit 1)
|
|| (echo_stamp "Some packages wasn't installed!" "ERROR"; exit 1)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
import math
|
import math
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
|
from collections import OrderedDict
|
||||||
import traceback
|
import traceback
|
||||||
from threading import Event
|
from threading import Event
|
||||||
import numpy
|
import numpy
|
||||||
@@ -631,32 +632,28 @@ def check_clever_service():
|
|||||||
elif 'failed' in output:
|
elif 'failed' in output:
|
||||||
failure('service failed to run, check your launch-files')
|
failure('service failed to run, check your launch-files')
|
||||||
|
|
||||||
|
r = re.compile(r'^(.*)\[(FATAL|ERROR)\] \[\d+.\d+\]: (.*?)(\x1b(.*))?$')
|
||||||
|
error_count = OrderedDict()
|
||||||
try:
|
try:
|
||||||
from systemd import journal
|
for line in open('/tmp/clever.err', 'r'):
|
||||||
except ImportError:
|
node_error = r.search(line)
|
||||||
failure('no python-systemd package, not the Clever image?')
|
if node_error:
|
||||||
return
|
msg = node_error.groups()[1] + ': ' + node_error.groups()[2]
|
||||||
|
if msg in error_count:
|
||||||
|
error_count[msg] += 1
|
||||||
|
else:
|
||||||
|
error_count.update({msg: 1})
|
||||||
|
else:
|
||||||
|
error_count.update({line.strip(): 1})
|
||||||
|
|
||||||
j = journal.Reader()
|
for error in error_count:
|
||||||
j.this_boot()
|
if error_count[error] == 1:
|
||||||
j.add_match(_SYSTEMD_UNIT='clever.service')
|
failure(error)
|
||||||
j.add_disjunction()
|
else:
|
||||||
j.add_match(UNIT='clever.service')
|
failure('%s (%d)', error, error_count[error])
|
||||||
node_errors = []
|
|
||||||
r = re.compile(r'^(.*)\[(FATAL|ERROR)\] \[\d+.\d+\]: (.*)$')
|
except IOError as e:
|
||||||
for event in reversed(list(j)):
|
failure('%s', e)
|
||||||
msg = event['MESSAGE']
|
|
||||||
if 'Started Clever ROS package' in msg:
|
|
||||||
break # we're done
|
|
||||||
elif ('[ERROR]' in msg) or ('[FATAL]' in msg):
|
|
||||||
msg = r.search(msg).groups()[2]
|
|
||||||
if msg in node_errors:
|
|
||||||
continue
|
|
||||||
node_errors.append(msg)
|
|
||||||
elif ('ERROR: ' in msg) or ('while processing' in msg) or ('Invalid roslaunch XML syntax' in msg):
|
|
||||||
node_errors.append(msg)
|
|
||||||
for error in reversed(node_errors):
|
|
||||||
failure(error)
|
|
||||||
|
|
||||||
|
|
||||||
@check('Image')
|
@check('Image')
|
||||||
|
|||||||
Reference in New Issue
Block a user