Message ID | 20170409205128.11560-2-arnout@mind.be |
---|---|
State | Superseded |
Headers | show |
Hello, On Sun, 9 Apr 2017 22:51:22 +0200, Arnout Vandecappelle (Essensium/Mind) wrote: > - kwargs['log'] = open(os.path.join(idir, "instance.log"), "a+") > + if kwargs['debug']: > + kwargs['log'] = sys.stdout > + else: > + kwargs['log'] = open(os.path.join(idir, "instance.log"), "a+") > log_write(kwargs['log'], "INFO: instance started") How does this works when you have several instances running in parallel? Everything gets mixed up on stdout? Thomas
On 10-04-17 10:22, Thomas Petazzoni wrote: > Hello, > > On Sun, 9 Apr 2017 22:51:22 +0200, Arnout Vandecappelle > (Essensium/Mind) wrote: > >> - kwargs['log'] = open(os.path.join(idir, "instance.log"), "a+") >> + if kwargs['debug']: >> + kwargs['log'] = sys.stdout >> + else: >> + kwargs['log'] = open(os.path.join(idir, "instance.log"), "a+") >> log_write(kwargs['log'], "INFO: instance started") > > How does this works when you have several instances running in > parallel? > > Everything gets mixed up on stdout? Indeed. I assume if you're debugging, you're not going to run several instances in parallel. Anyway, if you don't want this feature, just drop it. It's something I used while debugging the script and I thought could be useful for others as well. Regards, Arnout
diff --git a/scripts/autobuild-run b/scripts/autobuild-run index 64da088..2f0463d 100755 --- a/scripts/autobuild-run +++ b/scripts/autobuild-run @@ -101,6 +101,7 @@ Options: Defaults to %(--pid-file)s. -c, --config CONFIG path to configuration file Not set by default. + -d, --debug Send log output to stdout instead of log file --toolchains-url URL URL of toolchain configuration file Format of the configuration file: @@ -800,7 +801,10 @@ def run_instance(**kwargs): if not os.path.exists(idir): os.mkdir(idir) - kwargs['log'] = open(os.path.join(idir, "instance.log"), "a+") + if kwargs['debug']: + kwargs['log'] = sys.stdout + else: + kwargs['log'] = open(os.path.join(idir, "instance.log"), "a+") log_write(kwargs['log'], "INFO: instance started") while True: @@ -926,7 +930,8 @@ def main(): nice = (args['--nice'] or 0), toolchains_url = args['--toolchains-url'], upload = upload, - buildpid = buildpid + buildpid = buildpid, + debug = args['--debug'] )) p.start() processes.append(p)
While changing and debugging the autobuild-run script, it is convenient to be able to see the log directly on stdout rather than opening the log file. So provide an option for this. The option is called '--debug' with the idea that other debugging features added later can reuse the same option. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> --- scripts/autobuild-run | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)