app: Force register moonraker and klippy log endpoints
It is possible for the log files to be registered after a rollover, which can result in the file not existing. Force the log endpoints to register, bypassing the existance check. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
67f5b32d84
commit
ae3661b100
|
@ -132,9 +132,10 @@ class MoonrakerApp:
|
|||
# Register handlers
|
||||
logfile = config['system_args'].get('logfile')
|
||||
if logfile:
|
||||
self.register_static_file_handler("moonraker.log", logfile)
|
||||
self.register_static_file_handler(
|
||||
"moonraker.log", logfile, force=True)
|
||||
self.register_static_file_handler(
|
||||
"klippy.log", DEFAULT_KLIPPY_LOG_PATH)
|
||||
"klippy.log", DEFAULT_KLIPPY_LOG_PATH, force=True)
|
||||
self.auth.register_handlers(self)
|
||||
|
||||
def listen(self, host, port):
|
||||
|
@ -197,10 +198,10 @@ class MoonrakerApp:
|
|||
self.wsm.register_local_handler(api_def, callback)
|
||||
logging.info(msg)
|
||||
|
||||
def register_static_file_handler(self, pattern, file_path):
|
||||
def register_static_file_handler(self, pattern, file_path, force=False):
|
||||
if pattern[0] != "/":
|
||||
pattern = "/server/files/" + pattern
|
||||
if os.path.isfile(file_path):
|
||||
if os.path.isfile(file_path) or force:
|
||||
pattern += '()'
|
||||
elif os.path.isdir(file_path):
|
||||
if pattern[-1] != "/":
|
||||
|
|
|
@ -77,8 +77,10 @@ class FileManager:
|
|||
|
||||
# Register log path
|
||||
log_file = paths.get('log_file')
|
||||
log_path = os.path.normpath(os.path.expanduser(log_file))
|
||||
self.server.register_static_file_handler("klippy.log", log_path)
|
||||
if log_file is not None:
|
||||
log_path = os.path.normpath(os.path.expanduser(log_file))
|
||||
self.server.register_static_file_handler(
|
||||
"klippy.log", log_path, force=True)
|
||||
|
||||
def register_directory(self, root, path):
|
||||
if path is None:
|
||||
|
|
Loading…
Reference in New Issue