Repository navigation
Description
Problem to solve
Windows에서 ocx service install은 Task Scheduler 태스크를 InteractiveToken으로 등록하고 콘솔 배치 래퍼를 직접 실행하기 때문에, cmd 콘솔 창이 사용자 세션에 계속 표시됩니다. 사용자가 그 창을 닫으면 래퍼+프록시가 함께 죽어 모든 모델 연결이 끊깁니다(상세 진단은 연관 Bug 이슈 참조). macOS launchd·Linux systemd 사용자와 동일한 "창 없이 백그라운드에서 돌고, 실수로 죽일 수 없는" 서비스 경험이 Windows에도 필요합니다.
또한 README의 서비스 설명("starts on boot and stays out of your way")과 실제 Windows 동작(logon 트리거 + 보이는 콘솔 창)이 불일치하므로, 해결 전까지는 문서에 known limitation으로 명시할 필요가 있습니다.
Proposed solution
옵션 A를 우선 검증하고, 검증 매트릭스를 통과하지 못하면 옵션 B로 진행하는 순서를 제안합니다.
옵션 A — Task XML의 LogonType을 S4U로 전환 (최소 diff 후보)
buildWindowsTaskXml()의 <LogonType>을 S4U("Run whether user is logged on or not", 비밀번호 미저장)로 바꾸면 태스크가 비대화형으로 실행되어 창이 아예 생성되지 않습니다. 커뮤니티에서 Task Scheduler UI로 "로그인하지 않아도 실행"을 수동 적용해(이때 비밀번호를 입력했으므로 정확히는 Password 로그온 타입) 창이 사라진 것이 확인되었습니다 — 즉 "비대화형 실행이면 창이 사라진다"는 증거이지, 비밀번호 미저장 S4U 자체가 검증된 것은 아닙니다.
단, 확정 채택 전에 아래 검증 매트릭스를 통과해야 합니다:
- 로컬 계정 / Microsoft 계정(passwordless)에서
schtasks /create /xml등록 성공 여부 — 현재 XML에는 명시적<UserId>가 없어 단순 문자열 교체의 안정성이 미검증 - 실행 계정에
Log on as a batch job권한이 기본 부여되는지 (일반 사용자 / 기업 GPO 환경) - S4U는 네트워크 자격증명·EFS 접근이 없음 — 래퍼의
%USERPROFILE%/%APPDATA%환경 간접화, ACL hardened token 파일 읽기, 서비스 로그 쓰기가 S4U 세션에서 정상 동작하는지 - EFS 암호화 홈, UNC/custom
OPENCODEX_HOME, 기업 인증 프록시 환경 - 엔드투엔드 확인: S4U로 기동된 프록시에 실제 라우팅된 모델 요청을 보내 응답까지 확인 (파일/환경 체크만으로는 프록시의 핵심 아웃바운드 요청 경로가 증명되지 않음)
옵션 B — WinSW 기반 네이티브 Windows 서비스 등록 (구조적 해법)
WinSW로 프록시를 진짜 SCM 서비스로 등록하면 창 문제와 프로세스 수명 문제가 구조적으로 해소되고, 선언형 XML 설정·자동 재시작·로그 롤링을 얻습니다. 비용: 바이너리 동봉/배포 복잡도, 서비스 등록에 관리자 권한 필요. 릴리스 상태는 정확히: 저장소는 현재도 활동 중이나 최신 stable은 v2.12.0(2023)이고 3.x는 prerelease 계열입니다.
수용 기준 (어느 옵션이든)
- 서비스 설치 후 사용자 세션에 콘솔 창이 보이지 않음
- 사용자가 프로세스를 강제 종료해도 서비스 매니저가 자동 재시작 (Bug 이슈의 RestartOnFailure 실측 포함)
ocx service install/start/stop/status/uninstall계약 유지,OCX_SERVICE=1재주입 계약 유지- 중복 인스턴스 방지 유지 (현행
MultipleInstancesPolicy=IgnoreNew상당) - README 서비스 시맨틱 정정(채택 옵션에 맞게): S4U 채택 시 logon 트리거 유지를 명시, WinSW 채택 시 boot 시작 여부를 실제 구성에 맞게 서술 — 어느 쪽이든 현행 "starts on boot" 일괄 서술은 Windows에 대해 정정
docs/codex-path-investigation.mdWindows 서비스 절 동기화
Alternatives considered
- NSSM: 커뮤니티에서 제안된 우회책이고 여전히 동작하지만, 공식 정식판이 2.24(2014-08-31)이고 추천 prerelease도 2017년이라 신규 채택 후보로는 WinSW 대비 열위입니다.
- sc.exe 단독 등록: Node/Bun 프로세스가 SCM 서비스 컨트롤 프로토콜을 구현하지 않으므로 부적합합니다.
- VBS/PowerShell hidden 런처: 창만 숨기는 증상 완화책. 창이 없어지므로 창-닫기 사망 경로도 함께 사라지지만, 진짜 서비스 시맨틱(SCM 관리, 부팅 시작)은 얻지 못합니다.
- 현상 유지 + 문서 안내: Task Scheduler UI에서 수동으로 "Run whether user is logged on or not"를 선택하도록 안내 — 사용자마다 수동 설정이 필요하고 비밀번호 입력을 요구할 수 있어 근본 해결이 아닙니다.
Additional context
- 연관 Bug 이슈: [Bug]: Windows 서비스 설치 시 콘솔 창이 표시되고, 창을 닫으면 프록시가 죽어 모든 모델 연결이 끊김 #165
- https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-logontype-simpletype
- https://learn.microsoft.com/en-us/windows/win32/taskschd/security-contexts-for-running-tasks
- https://github.com/winsw/winsw / https://github.com/winsw/winsw/releases
- https://www.nssm.cc/download
Activity
lidge-jun commentedon Jul 19, 2026
방향 결정: 창 없는 Scheduler 기본 + WinSW --native 옵트인
독립 아키텍처 검토(sol 서브에이전트)를 거쳐 아래 방향으로 확정하고 구현했습니다.
확정 형태
기본 경로(Task Scheduler) 수리 —
ocx service install이 기존대로 Task Scheduler +InteractiveToken을 사용하되, wscript.exe VBS 런처(창 스타일 0, 상주)로 콘솔 창을 제거합니다. 자격증명이 불필요하므로 passwordless Microsoft 계정도 그대로 동작합니다. #165의 두 증상(창 노출 + 창 닫기 사망)이 모두 해소됩니다.옵트인 네이티브 —
ocx service install --native가 WinSW 2.12.0(NET461 빌드, SHA-256 핀 검증)으로 진짜 SCM 서비스를 사용자 계정으로 등록합니다. LocalSystem은 금지(ACL hardening이 사용자 SID에만 grant하므로 SYSTEM은 토큰 파일을 못 읽음). 부팅 시작, SCM 표준 복구, services.msc 관리가 가능해집니다.backend 영속화 —
service-state.jsonv2에 backend 선택을 기록하고ocx update가 그 backend 그대로 재설치합니다. 양쪽 backend를 항상 질의해 충돌(둘 다 설치됨)을 감지합니다.승격 보류 — WinSW를 기본값으로 승격하는 것은 아래 실측 매트릭스 통과 후의 별도 결정입니다.
WinSW를 기본값으로 올리지 않은 이유 (sol 분석 요지)
구현 커밋
77b966ca— hidden VBS 런처 ([Bug]: Windows 서비스 설치 시 콘솔 창이 표시되고, 창을 닫으면 프록시가 죽어 모든 모델 연결이 끊김 #165 수리)dd40e318— WinSW --native 옵트인 + state v2 + CLI 인자 파싱 + 앱 차원 토큰 로딩733c0dd6— sol 감사 blocker 수정 (stopwait race, transactional switch, conflicting flags)Windows 실측 요청 매트릭스
아래 항목은 macOS 개발 환경에서 검증 불가하므로 Windows 사용자의 실측이 필요합니다:
schtasks /run정상 기동,schtasks /end후 wscript/배치/자식 종료 범위docs(devlog): windows service console-window investigation + issues #165
feat(service): opt-in native Windows service backend via WinSW (--nat…
feat(service): backend-preserving update paths + README SoT correction (
lidge-jun commentedon Jul 20, 2026
구현 완료되어
dev에 랜딩했습니다. 다음 릴리스에 포함됩니다.최종 형태 (위 댓글의 확정 방향 그대로):
ocx service install이 WScript hidden 런처 경유로 콘솔 창 없이 실행 (77b966c). 관리자 권한·비밀번호 불필요.ocx service install --native(WinSW v2.12, dd40e31): 진짜 SCM 서비스, 로그 롤링,install /p자격증명 프롬프트, LocalSystem 등록 시 자동 롤백.ocx update가 같은 backend로 재설치 (b2bd6ce). 두 backend 공존은 트랜잭셔널 전환으로 차단.luvs01 commentedon Jul 30, 2026
Windows 실측 후속:
schtasks /end뒤 hidden CMD 감독자 잔류#166에서 요청하신 Windows 실측 매트릭스 중 “
schtasks /end후 wscript/배치/자식 종료 범위”에 해당하는 관찰 1건을 공유드립니다.환경과 한계
2.7.43, Task Scheduler backend (InteractiveToken)2.7.43이 생성한 WScript hidden launcher 및opencodex-service.cmd1.3.14가 아니라 사용자 지정1.4.0-canary.1+b22e0e6d0관찰
11:29:14에ocx service stop을 실행했고,11:29:17에 exit code 0과 다음 성공 메시지가 반환됐습니다.약 20초 뒤 Task Scheduler 상태는
Ready였지만, 동일한 hidden batch 감독자cmd.exePID 43812가 계속 존재했습니다. 이 프로세스는10:01:33에 생성됐고 명령줄은 생성된opencodex-service.cmd를 가리켰습니다. 당시 자식 Bun PID 5036도 남아 있었습니다.성공 메시지 이후의 서비스 로그에는 다음 순서가 기록됐습니다.
11:29:57에 해당 PID와 명령줄로 정확히 식별한 프로세스 트리만 점검했을 때, 감독자 PID 43812의 현재 자식은 새 Bun PID 41944로 바뀌어 있었습니다. 즉 예약 작업은 종료 상태였지만 기존 batch 감독자가 살아남아service stop뒤에도 자식을 다시 생성했습니다. 그 정확한 wrapper/child 트리를 종료한 뒤에는 둘 다 사라졌습니다.현재 코드와의 일치
현재
dev(67c731e)에서도 scheduler stop은schtasks /end만 호출하고, VBS는WScript.Shell.Run(..., 0, True)로 batch 종료를 기다리며, batch는 자식이 비정상 종료되면 5초 후 다시 시작합니다. 따라서schtasks /end가 하위 CMD 트리까지 끝내지 못하는 경우를stopWindows()가 검증하지 않는 현재 구조와 관찰이 일치합니다.이것만으로 모든 기본 설치에서 재현된다고 주장하지는 않습니다. 다만 scheduler backend의 stop 계약은 성공을 반환하기 전에 launcher/wrapper/child 트리가 실제로 소멸했는지 확인하거나, batch 루프가 명시적인 stop 신호를 인식하도록 하는 후속 보강이 필요해 보입니다.
Translated Message
Original language: Korean
Follow-up on Windows Measurement: Remaining Hidden CMD Supervisor After
schtasks /endI am sharing one observation related to the "scope of termination of wscript/batch/child after
schtasks /end" requested in #166 as part of the Windows measurement matrix.Environment and Limitations
2.7.43, Task Scheduler backend (InteractiveToken)opencodex-service.cmdcreated by2.7.431.4.0-canary.1+b22e0e6d0rather than the bundled1.3.14Observations
At
11:29:14, I executedocx service stop, and at11:29:17, it returned exit code 0 and the following success message.About 20 seconds later, the Task Scheduler state was
Ready, but the same hidden batch supervisorcmd.exePID 43812 continued to exist. This process was created at10:01:33and its command line pointed to the generatedopencodex-service.cmd. At that time, the child Bun PID 5036 was also still present.The service log after the success message recorded the following sequence.
At
11:29:57, when I checked the process tree identified exactly by that PID and command line, the current child of supervisor PID 43812 had changed to a new Bun PID 41944. That is, the scheduled task was in a stopped state, but the existing batch supervisor remained alive and recreated its child afterservice stop. After terminating the exact wrapper/child tree, both disappeared.Alignment with Current Code
As of the current
dev(67c731e), the scheduler stop only callsschtasks /end, and VBS waits for batch termination withWScript.Shell.Run(..., 0, True), while the batch restarts 5 seconds after an abnormal termination of the child. Therefore, the observation thatschtasks /enddoes not finish the lower CMD tree aligns with the current structure that does not verify whether the launcher/wrapper/child tree has actually been destroyed before returning success for the scheduler backend stop contract, or that the batch loop needs to recognize an explicit stop signal.This alone does not claim to be reproducible on all basic installations. However, it appears that subsequent enhancements are needed to ensure that the stop contract for the scheduler backend verifies the actual destruction of the launcher/wrapper/child tree before returning success, or for the batch loop to explicitly recognize the stop signal.
github-actions commentedon Jul 30, 2026
Automated translation bookkeeping — detected language: Korean.
docs(devlog): windows service console-window investigation + issues l…
feat(service): opt-in native Windows service backend via WinSW (--nat…
feat(service): backend-preserving update paths + README SoT correction (