Crowny Today VPS 배포 (2026-07-17)
개요
사장님 지시로 Crowny Today 백엔드(팀 하루 기록 앱)를 카페24 VPS(takeurban.art 서버 재사용, 1.234.20.240)에 배포. 기존 nginx(80/443, take.service:9944)와 공존, 무접촉.무엇을 했는지
1. 경로 이식성 수정 (맥 로컬 무손상)
서버.한선에 하드코딩된 맥 절대경로 3곳(데이터루트, 앱경로, bridge.js 경로)을 /opt/today/HOME.txt 존재 여부로 분기하는 방식으로 이식화.
- 한선씨에 환경변수 읽기 내장이 없어
체계("test -f /opt/today/HOME.txt && echo 1 > /tmp/ct_home.txt || echo 0 > ...")+읽기()로 시작 시 1회 분기. - 맥: HOME.txt 없음 → 기존 경로(
/Users/ef/crowny-today/...) 유지. - VPS: HOME.txt 있음 →
/opt/today/data,/opt/today/app/index.html,/opt/today/bridge.js. - 맥 재컴파일+재기동 후 회귀: health/GET //bridge.js/login/posts 전부 200 확인 (라이브 무손상).
2. VPS 셋업
/opt/today/{data,app}생성.- crownyc.c는 단일파일이 아니라
#include로 crowny_media.c, crowny_tls.c(APPLE 가드라 리눅스는 무동작), crownyc_jit.c, stb_image.h, stb_truetype.h 의존 — 5개 파일 전부 업로드해야 컴파일됨(1차 시도는 각각 fatal error로 하나씩 발견). cc -O2 -o crownyc crownyc.c -lpthread -lm— 경고만 있고 정상 빌드.- 서버.toau(맥 hanseonc_high 산출물, 플랫폼 무관 바이트코드) + app/index.html(4.2MB) + bridge.js + data/.psv rsync 업로드.
- 수동 기동
./crownyc run 서버.toau→ curl health 확인 후 systemd 유닛 등록.
3. systemd
/etc/systemd/system/today.service:
WorkingDirectory=/opt/today
ExecStart=/opt/today/crownyc run /opt/today/서버.toau
Restart=always
RestartSec=3
systemctl enable today && systemctl start today — enabled, active, 재시작 테스트(systemctl restart today) 후 health 200 재확인.4. nginx
/etc/nginx/sites-available/today.crowny.org 신규 파일(listen 80, proxy_pass 127.0.0.1:9604, proxy_set_header Host/X-Real-IP/X-Forwarded-For). sites-enabled 심볼릭 링크. nginx -t 통과 후 reload.
- takeurban.art 블록 무변경 확인:
nginx -t통과 +curl -H "Host: takeurban.art" http://1.234.20.240/301(http→https 기존 동작) +https://takeurban.art/200 회귀 정상.
5. HTTPS 보류
- A레코드가 아직 맥(112.144.147.144)을 가리킴 → certbot 지금 실행 불가.
- VPS에 certbot 1.21.0 이미 설치돼 있음(snap 설치 불필요, 확인만 함).
- VPS 직결 검증:
curl -H "Host: today.crowny.org" http://1.234.20.240/health→ 200.
검증 증거 (curl 원문)
VPS 로컬(127.0.0.1:9604):
health: {"ok":true,"service":"crowny-today","version":"1.0.0"}
GET /: <!doctype html>...Crowny Today 로그인...
bridge.js: 200
login(E01/aimed2026): {"ok":true,"token":"E01....","id":"E01","name":"이선우","role":"admin"}
posts(with token): {"ok":true,"posts":[...]}
VPS nginx 경유(Host: today.crowny.org, IP 1.234.20.240 직결):
health: {"ok":true,"service":"crowny-today","version":"1.0.0"} (200)
GET /: 200
bridge.js: 200
login: {"ok":true,"token":"...","name":"이선우","role":"admin"}
posts: {"ok":true,"posts":[...]}
맥 회귀(재컴파일+재기동 후, 배포 전/후 양쪽 확인):
http://127.0.0.1:9604/health: {"ok":true,...}
https://today.crowny.org/health (맥 게이트웨이 경유, 배포 후 그대로): 200 {"ok":true,...}
takeurban.art 회귀:
http://1.234.20.240/ (Host: takeurban.art): 301 (기존 http→https 리다이렉트, 정상)
https://takeurban.art/: 200
관련 파일
/Users/ef/crowny-today/서버.한선— 경로 이식 수정 (데이터루트/_앱경로/_브릿지경로 + HOME.txt 분기)/Users/ef/crowny-today/서버.toau— 재컴파일 산출물(맥·VPS 공용 바이트코드)/Users/ef/crowny-today/배포.sh— VPS 배포 스크립트(신규, crowny-take/배포.sh 패턴)/Users/ef/crowny-today/배포.conf— TODAY_VPS=root@1.234.20.240 등- VPS:
/opt/today/{crownyc, crownyc.c, crowny_media.c, crowny_tls.c, crownyc_jit.c, stb_image.h, stb_truetype.h, 서버.toau, bridge.js, app/index.html, data/, HOME.txt} - VPS:
/etc/systemd/system/today.service - VPS:
/etc/nginx/sites-available/today.crowny.org(+ sites-enabled 링크)
잔여 이슈 (A레코드 전환 후 절차)
- DNS: today.crowny.org A레코드를 맥(112.144.147.144) → VPS(1.234.20.240)로 전환.
- 데이터 동기화 (전환 전 필수): 전환 직전 맥의 최신 data/.psv를 VPS로 최종 rsync 1회 —
rsync -avz -e "ssh -i ~/.ssh/take_deploy" --exclude='launchd.*.log' \
/Users/ef/crowny-today/data/ root@1.234.20.240:/opt/today/data/
ssh -i ~/.ssh/take_deploy root@1.234.20.240 "systemctl restart today"
(append-log 구조라 전환 시점 이후 맥 쪽 신규 게시물은 유실되므로 전환 직전에 실행하고, 전환 후엔 맥 today 서비스를 내려 이중 라이브 방지 권장.)
- certbot 실행 (A레코드 전파 확인 후):
ssh -i ~/.ssh/take_deploy root@1.234.20.240 "certbot --nginx -d today.crowny.org --non-interactive --agree-tos -m tonemaestro@gmail.com"
- 맥 today 서비스 처리: 전환 완료 후
launchctl unload ~/Library/LaunchAgents/org.crowny.today.plist로 맥 로컬 중복 기동 방지(게이트웨이가 더 이상 맥으로 라우팅 안 하면 무해하지만 정리 권장). - 이후 코드 변경은
/Users/ef/crowny-today/배포.sh로 VPS 반영(--with-data는 데이터 재이관 시에만).