fix(reflect/scheduler): ensure sche_tasks/ exists before opening log file
scheduler.py:23 immediately does logging.FileHandler(sche_tasks/scheduler.log) at module load. .gitignore excludes sche_tasks/ entirely, so any fresh deploy (clone + run) crashes with FileNotFoundError before scheduler even gets to its main loop. The author's intent (line 76: 'if not os.path.isdir(TASKS): return None') is that sche_tasks/ should be optional — scheduler gracefully no-ops when it's missing. The top-level FileHandler call violates that. Fix: makedirs before opening the log. Mirrors the makedirs already done for DONE/ inside check() at line 78. After this lands, any GA deployment (Tauri / Squishy / kw / launch.pyw) can start scheduler without manual mkdir, and L4 archive cron runs from day one. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
439a5ef198
commit
ac2779d97d
1 file changed
+3
@@ -20,6 +20,9 @@ _LOG = os.path.join(_dir, '../sche_tasks/scheduler.log')
|
||||
_logger = logging.getLogger('scheduler')
|
||||
if not _logger.handlers:
|
||||
_logger.setLevel(logging.INFO)
|
||||
# sche_tasks/ 在 .gitignore 里,fresh deploy 时不存在,先建出来再开 FileHandler
|
||||
# (跟 check() 里 line 78 的 os.makedirs(DONE, exist_ok=True) 是一个 pattern)
|
||||
os.makedirs(os.path.dirname(_LOG), exist_ok=True)
|
||||
_fh = logging.FileHandler(_LOG, encoding='utf-8')
|
||||
_fh.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M'))
|
||||
|
||||
Reference in new issue
Block a user