[yocto] [autobuilder][PATCH 4/4] janitor: clean up janitor logging

Joe MacDonald joe_macdonald at mentor.com
Tue Feb 17 13:41:15 PST 2015


If OPTIMIZED_GIT_CLONE was set, the worker janitor was start up and
depending on the system, produce an error of the form:

/bin/sh: line 1: 11093 Killed                  python bin/buildworker-janitor [path-to--autobuilder]/config/autobuilder.conf >> yocto-worker/janitor.log 2>&1

By removing the shell-redirect from the Popen() call and instead sending
all logs directly to a regular log file, the error goes to the log where
it belongs.  Since this happens regularly when the host is both a control
and a build node, this change also makes it clearer to the user that
something bad has not necessarily happened the first time they try to
start up the autobuilder.

At the same time, since the logs tend to not have much in them by way of
context, adding a timestamp to each new start of the janitor makes it much
easier when looking over the old logs to see if errors are current or long
in the past.

Signed-off-by: Joe MacDonald <joe_macdonald at mentor.com>
---
 yocto-start-autobuilder | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/yocto-start-autobuilder b/yocto-start-autobuilder
index 7078163..ee597df 100755
--- a/yocto-start-autobuilder
+++ b/yocto-start-autobuilder
@@ -20,7 +20,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import os, sys, optparse, subprocess
+import os, sys, optparse, subprocess, datetime
 from socket import gethostname
 import ConfigParser
 
@@ -79,10 +79,15 @@ if os.path.isfile(os.path.join(AB_BASE, ".setupdone")):
         os.chdir(AB_BASE)
         if os.environ["OPTIMIZED_GIT_CLONE"] == "True":
             os.chdir(AB_BASE)
-            subprocess.Popen("python bin/buildworker-janitor " + os.path.join(AB_BASE, "config/autobuilder.conf") + ">> yocto-worker/janitor.log 2>&1", 
+            janitor_log = open('yocto-worker/janitor.log', 'a')
+            janitor_log.write('[ janitor started: %s ]' % datetime.datetime.now())
+            janitor_log.write('\n')
+            subprocess.Popen("python bin/buildworker-janitor " + os.path.join(AB_BASE, "config/autobuilder.conf"), 
                            shell=True, stdin=None, 
-                           stdout=None, stderr=None, 
+                           stdout=janitor_log,
+                           stderr=janitor_log, 
                            close_fds=True)
+            janitor_log.close()
 else:
     print "You have not sourced ./yocto-autobuilder-setup. Please do so first!"
     print ""
-- 
1.9.1




More information about the yocto mailing list