> For the complete documentation index, see [llms.txt](https://docs.appstrategy.com/apprules-r-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appstrategy.com/apprules-r-documentation/platform/self-hosting/software-installation/hostservice.md).

# HostService Settings

Starting with appRulesPortal v9.0 (.NET 8 / Wisej 4), the former `appRules.HostService.exe` has been replaced by the **appRulesPortal kernel engine** — a self-hosted [Kestrel](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel) Windows Service that runs natively without IIS.

The portal now runs as **four coordinated Windows Services** that must all be installed and started together.

> **Note:** IIS is not required. See  [IIS Settings](/apprules-r-documentation/platform/self-hosting/software-installation/iis-setting.md) if you want to put IIS in front of Kestrel as a reverse proxy for SSL termination or port 80/443 routing.

***

### Prerequisites

| Requirement    | Details                                                                                       |
| -------------- | --------------------------------------------------------------------------------------------- |
| OS             | Windows Server 2019 / 2022                                                                    |
| .NET 8 Runtime | ASP.NET Core Runtime 8.x — [Download](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) |
| Redis          | Required by `appRules.CachingService`                                                         |
| SQL Server     | Required for the appRules metadata database                                                   |

***

### The Four Services

| Service Executable              | Display Name               | Role                                            |
| ------------------------------- | -------------------------- | ----------------------------------------------- |
| `appRulesPortal.exe`            | appRules Portal            | Kestrel web host — serves the Wisej application |
| `appRules.CachingService.exe`   | appRules Caching Service   | Redis-backed session and data cache             |
| `appRules.WebApiService.exe`    | appRules WebApi Service    | REST API layer                                  |
| `appRules.SchedulerService.exe` | appRules Scheduler Service | Background job scheduler                        |

All four executables are located in the `bin\` subfolder of the install directory (e.g. `[InstallationPath]\bin\`).

where \[InstallationPath]= appRulesPortal Folder Path

***

### Command-Line Arguments

#### `appRulesPortal.exe`

The portal executable uses standard ASP.NET Core hosting arguments:

| Argument                       | Description                                                                                                                                          |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--urls http://0.0.0.0:{port}` | Sets the listening URL and port. Default port is **8080**. Use `0.0.0.0` to accept all connections, or `localhost` to accept local connections only. |
| `--environment Production`     | Sets the runtime environment. Equivalent to `ASPNETCORE_ENVIRONMENT=Production`.                                                                     |

**Example — listen on all interfaces, port 8080:**

```bat
appRulesPortal.exe --urls http://0.0.0.0:8080
```

**Example — local connections only, custom port:**

```bat
appRulesPortal.exe --urls http://localhost:9000
```

> The companion services (`CachingService`, `WebApiService`, `SchedulerService`) take no command-line arguments. All their configuration is via `appsettings.json` / `appRules.WebApiService.appsettings.json`.

***

### Service Registration

#### Automated (recommended)

Use the provided PowerShell deployment script to install, configure, and start all four services in one step:

```powershell
# Deploy from Release folder to [InstallationPath] (default)
.\deploy_appRulesPortal.ps1

# Deploy to a custom path and port
.\deploy_appRulesPortal.ps1 -TargetDir "E:\appRulesPortal" -Port 8081
```

The script registers all services, sets `ASPNETCORE_ENVIRONMENT=Production`, and starts them in the correct order.

#### Manual

Register each service using `sc.exe`. All executables must use their **full path**:

```bat
set INSTALL_DIR=[InstallationPath]
set BIN_DIR=%INSTALL_DIR%\bin

sc.exe create "appRulesPortal" binPath= "\"%BIN_DIR%\appRulesPortal.exe\" --urls http://0.0.0.0:8080" DisplayName= "appRules Portal" start= auto
sc.exe create "appRules.CachingService" binPath= "\"%BIN_DIR%\appRules.CachingService.exe\"" DisplayName= "appRules Caching Service" start= auto
sc.exe create "appRules.WebApiService" binPath= "\"%BIN_DIR%\appRules.WebApiService.exe\"" DisplayName= "appRules WebApi Service" start= auto
sc.exe create "appRules.SchedulerService" binPath= "\"%BIN_DIR%\appRules.SchedulerService.exe\"" DisplayName= "appRules Scheduler Service" start= auto
```

Set `ASPNETCORE_ENVIRONMENT=Production` for each service via the registry:

```bat
reg add "HKLM\SYSTEM\CurrentControlSet\Services\appRulesPortal" /v Environment /t REG_MULTI_SZ /d "ASPNETCORE_ENVIRONMENT=Production" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\appRules.CachingService" /v Environment /t REG_MULTI_SZ /d "ASPNETCORE_ENVIRONMENT=Production" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\appRules.WebApiService" /v Environment /t REG_MULTI_SZ /d "ASPNETCORE_ENVIRONMENT=Production" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\appRules.SchedulerService" /v Environment /t REG_MULTI_SZ /d "ASPNETCORE_ENVIRONMENT=Production" /f
```

#### Starting and stopping

Services must be started in order — the portal depends on the three companion services being ready:

```bat
REM Start
sc.exe start "appRules.CachingService"
sc.exe start "appRules.WebApiService"
sc.exe start "appRules.SchedulerService"
sc.exe start "appRulesPortal"

REM Stop (reverse order)
sc.exe stop "appRulesPortal"
sc.exe stop "appRules.SchedulerService"
sc.exe stop "appRules.WebApiService"
sc.exe stop "appRules.CachingService"
```

#### Uninstalling

```bat
sc.exe delete "appRulesPortal"
sc.exe delete "appRules.CachingService"
sc.exe delete "appRules.WebApiService"
sc.exe delete "appRules.SchedulerService"
```

***

### Configuration Files

| File                                      | Location              | Purpose                                         |
| ----------------------------------------- | --------------------- | ----------------------------------------------- |
| `appsettings.json`                        | `[InstallationPath]\` | ASP.NET Core connection strings and settings    |
| `appsettings.Production.json`             | `[InstallationPath]\` | Production overrides (merged at runtime)        |
| `appRules.WebApiService.appsettings.json` | `bin\`                | WebApi service endpoint configuration           |
| `Default.json`                            | `[InstallationPath]\` | Wisej license key, default theme, startup class |

**Minimum `appsettings.json`:**

```json
{
  "ConnectionStrings": {
    "DefaultConnection": "Server=.;Database=appRules;Trusted_Connection=True;TrustServerCertificate=True;"
  }
}
```

**Minimum `Default.json` settings to verify:**

* `Wisej.LicenseKey` — production license key
* `Wisej.DefaultTheme` — e.g. `Bootstrap-4`
* `startup` — must be `"appStrategy.appRulesPortal.Program.WisejInit, appRulesPortal"`

***

### Changing the Port

Pass a different `--urls` argument when registering the service:

```bat
sc.exe create "appRulesPortal" binPath= "\"[InstallationPath]\bin\appRulesPortal.exe\" --urls http://0.0.0.0:9000" DisplayName= "appRules Portal" start= auto
```

To change the port on an already-registered service, delete and re-create it, or use `sc.exe config`:

```bat
sc.exe config "appRulesPortal" binPath= "\"[InstallationPath]\bin\appRulesPortal.exe\" --urls http://0.0.0.0:9000"
```

***

### Post-Installation Verification

| Check                | Command / How                                              |
| -------------------- | ---------------------------------------------------------- |
| All services running | `sc.exe query appRulesPortal` — should show `RUNNING`      |
| Portal accessible    | Browse to `http://server:8080/` — should show Wisej login  |
| WebSocket active     | Browser DevTools → Network → WS: `101 Switching Protocols` |
| deps.json patched    | `findstr "runtimes/win" bin\*.deps.json` returns nothing   |
| JSON files blocked   | `GET /appsettings.json` returns HTTP 403                   |
| License active       | No Wisej license warning banner                            |

***

### Troubleshooting

| Error                                                            | Cause                                                          | Fix                                                                                                   |
| ---------------------------------------------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| Service starts then immediately stops                            | Startup exception                                              | Check Windows Event Log: `eventvwr.msc` → Windows Logs → Application                                  |
| `FileNotFoundException: System.ServiceProcess.ServiceController` | `deps.json` not patched                                        | See `WindowsService-DepsJson-Patching.md`                                                             |
| `PlatformNotSupportedException`                                  | Portable DLL build in `bin\` instead of Windows-specific build | Copy from NuGet cache `runtimes\win\lib\net8.0\` — see deployment guide                               |
| Portal not accessible on port 8080                               | Firewall blocking port                                         | `netsh advfirewall firewall add rule name="appRules" dir=in action=allow protocol=TCP localport=8080` |
| JS / static assets not loading                                   | `staticwebassets.runtime.json` `ContentRoots` path wrong       | Re-run `deploy_appRulesPortal.ps1` or patch the file manually to the correct install path             |
| Access Denied on start                                           | Service account lacks folder permissions                       | Grant the service account (e.g. `LocalSystem`) read/write access to `[InstallationPath]\`             |

***

***

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.appstrategy.com/apprules-r-documentation/platform/self-hosting/software-installation/hostservice.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
