제7장 — 운영 및 관리

Last Updated: 2026-11-30 14:51 Views: 3

7.1 명령줄

플래그 목적
-c <path> 구성 파일; 기본값 ./conf/wxserver.toml, 다음 /etc/wxserver/wxserver.toml
-w <dir> 작업 디렉터리; 상대 pid/logs/run/html 경로의 기준
-t 구성 구문과 의미만 검증
-s reload / stop / quit PID에 신호 전송: SIGHUP은 리로드, SIGTERM은 정상 종료
-s start / restart / status 서비스 관리자 없이 백그라운드 제어
-no-manager 이번 실행에서 콘솔 비활성화
-v 버전 표시
wxserver -c /etc/wxserver/wxserver.toml
wxserver -t -c /etc/wxserver/wxserver.toml
wxserver -s reload -c /etc/wxserver/wxserver.toml
wxserver -s stop   -c /etc/wxserver/wxserver.toml
wxserver --service install -c /etc/wxserver/wxserver.toml
wxserver --service start   -c /etc/wxserver/wxserver.toml
wxserver --service status  -c /etc/wxserver/wxserver.toml

포터블 Windows 배포에서는 wxserver.exe에 -w "C:\WxServer"와 -c conf\wxserver.toml을 지정하면 상대 경로가 고정됩니다. 서비스로 설치하려면 -service-user .\wxserver -service-password ***(일반 로컬 사용자)를 추가합니다.

7.2 시스템 서비스

서비스 이름은 항상 wxserver이며, --service install이 플랫폼 관리자를 자동 감지합니다:

플랫폼 관리자 설치 위치
Linux systemd → OpenRC → SysV 자동 감지 /etc/systemd/system 또는 /etc/init.d
FreeBSD rc.d(daemon(8)) /usr/local/etc/rc.d
macOS launchd /Library/LaunchDaemons
Windows SCM sc create로 등록

--service install은 정의를 작성하고 등록합니다. start/stop/restart/ status는 플랫폼 관리자로 전달됩니다(Windows는 SCM 서비스 모드). 관리자가 없으면 PID 파일 + -s reload|stop|quit 모드로 폴백합니다.

7.3 리로드와 종료

-s reload 또는 콘솔의 “저장 후 리로드”는 실행 중인 구성을 원자적으로 교체 (arc-swap)하며 관리 API는 끊기지 않습니다. 리스너 주소 변경은 재시작이 필요합니다. 잘못된 구성은 리로드에 실패하고 이전 구성이 계속 서비스합니다.

-s stop과 -s quit은 동일합니다. SIGTERM을 보내고 진행 중인 요청은 최대 graceful_timeout_sec(기본 30초)까지 완료됩니다. 다중 워커에서는 마스터가 각 워커로 시그널을 전달합니다.

user, 리스너 포트 범위를 변경할 때는 유지 관리 창을 계획하십시오. 사이트, WAF, 캐시 설정만 변경하면 핫 리로드할 수 있습니다.

7.4 로그 및 로테이션

로그는 기본적으로 /var/log/wxserver/ 아래에 있습니다: access.$year-$month-$day.log(combined 형식), error.log, waf.log, stream.log, manager-login.log, manager-audit.log. 경로는 $year/$month/$day/$hour를 허용하며 날짜가 바뀌면 이전 파일이 gzip으로 아카이브됩니다.

max_size_mb와 max_backups가 크기와 보존을 제어합니다. 액세스 로그는 기본적으로 마스킹되며, encrypt = true로 각 줄이 AES-256-GCM으로 암호화됩니다. 암호화 로그는 콘솔 로그 페이지 또는 GET /api/logs/{name}으로 읽습니다(서버 측에서 자동 복호화).

7.5 백업 및 계정 복구

conf/(vhost/, certs/, manager.toml, acme.toml, cert.toml 포함)와 사이트 html/을 백업하십시오. run/에는 PID 파일, 공유 메모리, 설정된 경우 캐시가 있으며 백업할 필요가 없습니다. 업그레이드 시 바이너리를 교체하고 -t로 검증한 뒤 리로드하며, 메이저 버전 전에는 구성을 백업하십시오.

분실한 비밀번호는 wxserver --reset-password [password](여러 사용자면 --manager-user 사용), 분실한 인증 앱은 --reset-totp로 재설정합니다. 둘 다 manager.toml 또는 TOTP 상태만 변경합니다. 변경은 핫 리로드되며 자격 증명이 실제로 변경될 때만 이전 토큰이 무효화됩니다.

7.6 구성 및 규칙 변환 (wxserver-convert)

# nginx → TOML (파일 모드는 include를 확장하며, -out이 없으면 stdout으로 출력)
wxserver-convert -from nginx -in nginx.conf -out conf/wxserver.toml
# nginx → 메인 구성 + 사이트당 하나의 conf/vhost/*.toml
wxserver-convert -from nginx -in nginx.conf -out conf/wxserver.toml --split-vhosts conf/vhost
# Apache .htaccess → 붙여넣기 가능한 로케이션 조각(.htaccess 자동 감지)
wxserver-convert -in .htaccess --prefix /blog/ -out /tmp/blog.toml
# OWASP CRS / ModSecurity → TOML (여러 -in 병합)
wxserver-convert -from crs -in crs-setup.conf -in rules/*.conf -out conf/waf/crs.toml
  • --split-vhosts는 명시적 name 또는 첫 번째 domain으로 사이트 이름을 정합니다. 한 도메인에 80⁄443 사이트가 모두 있으면 평문 사이트는 <domain>-http가 됩니다. 대상 디렉터리는 메인 구성 디렉터리 내부에 있어야 합니다.
  • 지원되지 않는 디렉티브는 중단 없이 stderr에 warning: 줄을 출력합니다 (-quiet로 억제). 출력은 쓰기 전에 TOML 파싱 검사를 거칩니다.
  • nginx 주요 변환: gzip*는 레벨별로 기록됩니다. set_real_ip_from/ real_ip_header는 [modules.http_realip]로 매핑됩니다(real_ip_recursive on → mode="recursive"). ssl_ciphers는 rustls가 지원하는 AEAD 스위트만 유지합니다. image_filter resize|crop → type="image" + default_mode, valid_referers + if ($invalid_referer) → referer, add_header ... always → add_headers_always, log_format → access_log.format_template입니다. 명명된 로케이션과 try_files ... @name은 그대로 이어지며, 일반적인 if 부분 집합은 구조화된 if로 변환됩니다.

7.7 wxserver-tool

# htpasswd: bcrypt 항목을 0600 파일에 기록하며 대화형 모드는 입력을 숨깁니다
wxserver-tool htpasswd -f conf/htpasswd                 # 대화형
wxserver-tool htpasswd -f conf/htpasswd -u alice -p 'secret'
wxserver-tool htpasswd --check -f conf/htpasswd -u alice -p 'secret'

# bench: ab 스타일 부하 테스트, RPS와 P50/P90/P99 지연시간을 출력합니다
wxserver-tool bench http://127.0.0.1:8080/ -n 1000 -c 50
wxserver-tool bench http://127.0.0.1:8080/api -n 200 -c 10 -m POST -H 'Content-Type: application/json' -d '{"x":1}'
wxserver-tool bench https://self-signed.local/ -n 50 -c 5 -k   # TLS 검증 건너뛰기

# toml: TOML 1.1 → JSON (python tomllib은 멀티라인 인라인 테이블을 읽지 못함)
wxserver-tool toml conf/wxserver.toml                   # JSON으로
wxserver-tool toml --rewrite conf/vhost/example.toml    # 제자리 정규화(주석 유지)

# precompress: .gz/.br/.zst 사이드카를 생성합니다
wxserver-tool precompress --dir html
← Previous Article 제6장 — 성능 및 캐싱 Next Article → 제8장 — 모듈

Comments

No comments yet