From dc465af5591e681040477bfce8df2c32eaf99498 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Sat, 14 Jun 2014 00:19:43 +0000 Subject: [PATCH] If the console has successfully been opened up but then on subsequent opens suffers an I/O error, weewx will now attempt a retry (before it would just exit). --- bin/weewx/wxengine.py | 22 +++++++++++++++------- docs/changes.txt | 4 ++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/bin/weewx/wxengine.py b/bin/weewx/wxengine.py index 83bdf090..bea5fa2e 100644 --- a/bin/weewx/wxengine.py +++ b/bin/weewx/wxengine.py @@ -930,6 +930,11 @@ def main(options, args, EngineClass=StdEngine) : syslog.syslog(syslog.LOG_INFO, "wxengine: pid file is %s" % options.pidfile) daemon.daemonize(pidfile=options.pidfile) + # If an exception occurs the first time through, then the problem is most likely + # a configuration problem. But, if it happens later, it could be I/O error and + # it's worth retrying + successful_init = False + while True: os.chdir(cwd) @@ -944,20 +949,23 @@ def main(options, args, EngineClass=StdEngine) : else: syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_INFO)) - # Create and initialize the engine - engine = EngineClass(config_dict) - - # Start the engine - syslog.syslog(syslog.LOG_INFO, "wxengine: Starting up weewx version %s" % weewx.__version__) - try: + syslog.syslog(syslog.LOG_DEBUG, "wxengine: Initializing engine") + + # Create and initialize the engine + engine = EngineClass(config_dict) + successful_init = True + + syslog.syslog(syslog.LOG_INFO, "wxengine: Starting up weewx version %s" % weewx.__version__) + + # Start the engine engine.run() # Catch any recoverable weewx I/O errors: except weewx.WeeWxIOError, e: # Caught an I/O error. Log it, wait 60 seconds, then try again syslog.syslog(syslog.LOG_CRIT, "wxengine: Caught WeeWxIOError: %s" % e) - if options.exit : + if options.exit or not successful_init: syslog.syslog(syslog.LOG_CRIT, " **** Exiting...") sys.exit(weewx.IO_ERROR) syslog.syslog(syslog.LOG_CRIT, " **** Waiting 60 seconds then retrying...") diff --git a/docs/changes.txt b/docs/changes.txt index baee28b7..1cc04680 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -27,6 +27,10 @@ Prompt for metric/US units for debian installations. For WS28xx stations, return 0 for battery ok and 1 for battery failure. +If the console has successfully been opened up but then on subsequent opens +suffers an I/O error, weewx will now attempt a retry (before it would just +exit). + 2.6.3 04/10/14