Windows Service that launches and manages the opencode CLI as a persistent web server (opencode web).
- Runs as a Windows Service named OpencodeWeb
- Spawns
opencode web --port <port> --hostname <hostname>on startup - Sets
OPENCODE_SERVER_USERNAMEandOPENCODE_SERVER_PASSWORDenvironment variables for the child process - Captures stdout/stderr and forwards them to the Windows Event Log
- Auto-restarts opencode after a 5-second delay if the process exits unexpectedly
- .NET 11 SDK (preview)
- opencode CLI installed and on
PATH(or specify a full path in config)
Edit appsettings.json in the publish output (or appsettings.Development.json for debug runs):
{
"Opencode": {
"Path": "opencode",
"Port": "4096",
"Hostname": "127.0.0.1",
"Username": "opencode",
"Password": ""
}
}| Key | Description |
|---|---|
Path |
Fallback command name if PATH resolution fails (default: opencode) |
Port |
TCP port for the web server (default: 4096) |
Hostname |
Bind hostname (default: 127.0.0.1) |
Username |
HTTP Basic Auth username via OPENCODE_SERVER_USERNAME |
Password |
HTTP Basic Auth password via OPENCODE_SERVER_PASSWORD |
dotnet build -c Releasedotnet publish -c Release -o .\distsc create OpencodeWeb binPath="<full-path>\dist\OpenCodeWebService.exe"
sc start OpencodeWebsc stop OpencodeWeb
sc delete OpencodeWeb