← 전체로 돌아가기
프로젝트 메모 shell -etc-nginx

hub-daily-cron setup

hub 사이트 자동 재생성 및 daily cron 설정

nginxpythoncrondocker

hub-daily-cron

/home/son/prj/dev_portfolio/generate-hub.py 실행 시 두 개 허브 한 번에 재생성됨.

  1. Main hub (hub.ericfromkorea.com)
  2. /etc/nginx/sites-enabled/ 스캔해서 # hub-title:/desc/order 주석 메타데이터 읽음
  3. hub-extras.json 머지해서 fe/index.html, fe/hub.html 생성
  4. dev-portfolio-fe 도커 컨테이너 rebuild (port 60022)
  5. sites-available에 있어도 symlink 안 되어 있으면 건너뜀 (정상)

  6. Learn sub-hub (learn.ericfromkorea.com)

  7. sub-pages 찾는 법 2가지:
  8. (a) nginx config 내 location 경로 (proxied apps용)
  9. (b) webroot 내 index.html 있는 디렉토리 (static pages용)
  10. learn-sub-meta.json 머지해서 static index.html 생성
  11. JSON에서 "hidden": true 하면 목록에서 숨김 처리됨

Daily cron (crontab) 0 11 * * * cd /home/son/prj/dev_portfolio && /usr/bin/python3 generate-hub.py >> [로그경로] 2>&1

  • pyenv shim 안 쓰고 system /usr/bin/python3 직접 지정함 (cron PATH 지저분해서 안 믿음)
  • crontab 백업은 /home/son/.crontab_backup/ 에 저장

주의사항 - 도커 rebuild 할 때 잠시(몇 초) 메인 허브 다운됨 (learn은 static이라 괜찮음) - /var/www/learn.ericfromkorea.com/ 권한 문제 있음. root 소유라 따로 처리 필요.

여기서 배울 것

  1. cron에서는 pyenv 대신 system python 쓰는 게 정신건강에 좋음
  2. nginx sites-enabled 기반으로 스캔하는 게 깔끔함
  3. 도커 rebuild 시 짧은 다운타임 발생함
원본 파일 보기 (.claude/projects/-etc-nginx/memory/hub-daily-cron.md)
---
name: hub-daily-cron
description: How hub.ericfromkorea.com + learn.ericfromkorea.com hubs are generated and the daily cron that rebuilds them
metadata: 
  node_type: memory
  type: project
  originSessionId: 3eac8adb-fd0e-4fbc-b45a-9d4cc1700c85
---

`/home/son/prj/dev_portfolio/generate-hub.py` regenerates two hubs in one run:
- **Main hub** (`hub.ericfromkorea.com`): scans `/etc/nginx/sites-enabled/` for `# hub-title:/desc/order` comment metadata + merges `hub-extras.json`, writes `fe/index.html`+`fe/hub.html`, then **rebuilds the `dev-portfolio-fe` Docker container** (port 60022). Reads sites-**enabled** only, so a config sitting in sites-available but not symlinked won't appear (this is correct — only served sites show).
- **Learn sub-hub** (`learn.ericfromkorea.com`): discovers sub-pages from TWO sources — (a) content-serving `location` paths in the learn nginx config (`detect_sub_paths`, for proxied apps like /thesis/, /video-to-image/), and (b) webroot subdirs containing an `index.html` (`detect_static_paths`, added 2026-05-31, for filesystem static pages like /pixel-art/, /gisa/, /isaac-study/, /small-vlm/ that are served via `location /`+try_files and have NO nginx location block). Merges titles/descs from `learn-sub-meta.json`, writes static `index.html`. Entries hidden with `"hidden": true` in that JSON (e.g. the `/dataset-viewer/` hyphen-alias dup of `/dataset_viewer/`).

**Daily cron** (son's crontab, added 2026-05-31): `0 11 * * * cd /home/son/prj/dev_portfolio && /usr/bin/python3 generate-hub.py >> .../hub-cron.log 2>&1`. Uses system `/usr/bin/python3` (NOT the pyenv shim) deliberately — script is pure stdlib, and pyenv shims are unreliable under cron's minimal PATH. Crontab backups in `/home/son/.crontab_backup/`.

Caveats: (1) the Docker rebuild does stop→rm→run, so hub.ericfromkorea.com is briefly down (~seconds) at 11:00 (learn is static, no downtime). (2) Hub regen requires son to be able to overwrite `/var/www/learn.ericfromkorea.com/index.html` — that dir is root-owned, see [[learn-webroot-reroots]].