Skip to content

Commit

Permalink
document updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaneri committed Jan 20, 2025
1 parent 4f1b48a commit 34b367f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion docs/Getting-Started/Console.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Console Feature Overview
# Console Output

Pode introduces a configurable **console output** feature, enabling you to monitor server activities, control its behavior, and customize the console's appearance and functionality to suit your needs. The console displays key server information such as active endpoints, OpenAPI documentation links, and control commands.

Expand Down
3 changes: 2 additions & 1 deletion docs/Hosting/RunAsService.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

Rather than having to manually invoke your Pode server script each time, it's best if you can have it start automatically when your computer/server starts. Below you'll see how to set your script to run as either a Windows or a Linux service.

> **Note**: When running Pode as a service, it is recommended to use `Start-PodeServer` with the `-Daemon` parameter. This ensures the server operates in a detached and background-friendly mode suitable for long-running processes. The `-Daemon` parameter optimizes Pode's behavior for service execution by suppressing interactive output and allowing the process to run seamlessly in the background.
!!! Note
When running Pode as a service, it is recommended to use `Start-PodeServer` with the `-Daemon` parameter. This ensures the server operates in a detached and background-friendly mode suitable for long-running processes. The `-Daemon` parameter optimizes Pode's behavior for service execution by suppressing interactive output and allowing the process to run seamlessly in the background.

## Windows

Expand Down
2 changes: 1 addition & 1 deletion docs/Tutorials/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Start-PodeServer {
}
```

### Explicit Loading with `-ConfigFile`
### Custom Config Path

Pode also allows you to explicitly specify a configuration file using the `-ConfigFile` parameter when starting the server. This is useful if you want to load a configuration file from a custom location.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ The **Disable** operation blocks new incoming requests to the Pode server by int
### How It Works

1. **Blocking Requests**:
- All new incoming requests are intercepted and responded to with a `503 Service Unavailable` status.
- A `Retry-After` header is included in the response, advising clients when they can attempt to reconnect.
- All new incoming requests are intercepted and responded to with a `503 Service Unavailable` status.
- A `Retry-After` header is included in the response, advising clients when they can attempt to reconnect.

2. **Customizing Retry Time**:
- The retry time (in seconds) can be customized to specify when the service is expected to become available again. By default, this is set to **1 hour**.
- The retry time (in seconds) can be customized to specify when the service is expected to become available again. By default, this is set to **1 hour**.

### Example Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Pode introduces the ability to configure and control server behaviors using the
Disable = $true # Enable or disable the disable operation
DisableSettings = @{
RetryAfter = 3600 # Default retry time (in seconds) for Disable-PodeServer
MiddlewareName = '__Pode_Midleware_Code_503' # Name of the middleware scriptblock
MiddlewareName = '__Pode_Midleware_Code_503__' # Name of the middleware scriptblock
}
Timeout = @{
Suspend = 30 # Maximum seconds to wait before suspending
Expand All @@ -42,11 +42,11 @@ Pode introduces the ability to configure and control server behaviors using the
2. **Restart**: Allows you to enable or disable server restarts.
3. **Disable**: Controls whether the server can block new incoming requests using `Disable-PodeServer`.
4. **DisableSettings**:
- `RetryAfter`: Specifies the default retry time (in seconds) included in the `Retry-After` header when the server is disabled.
- `MiddlewareName`: Defines the name of the middleware scriptblock responsible for handling `503 Service Unavailable` responses.
- `RetryAfter`: Specifies the default retry time (in seconds) included in the `Retry-After` header when the server is disabled.
- `MiddlewareName`: Defines the name of the middleware scriptblock responsible for handling `503 Service Unavailable` responses.
5. **Timeout**:
- `Suspend`: Defines the maximum wait time (in seconds) for runspaces to suspend.
- `Resume`: Defines the maximum wait time (in seconds) for runspaces to resume.
- `Suspend`: Defines the maximum wait time (in seconds) for runspaces to suspend.
- `Resume`: Defines the maximum wait time (in seconds) for runspaces to resume.

### Benefits of Allowed Actions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ To suspend a running Pode server, use the `Suspend-PodeServer` function. This fu
The `-Timeout` parameter specifies how long the function should wait (in seconds) for each runspace to be fully suspended. This is optional, with a default timeout of 30 seconds.

2. **Suspension Process**:
- When you run `Suspend-PodeServer`, Pode will:
- Pause all runspaces associated with the server, putting them into a debug state.
- Trigger a "Suspend" event to signify that the server is paused.
- Update the server’s status to reflect that it is now suspended.
- When you run `Suspend-PodeServer`, Pode will:
- Pause all runspaces associated with the server, putting them into a debug state.
- Trigger a "Suspend" event to signify that the server is paused.
- Update the server’s status to reflect that it is now suspended.

3. **Outcome**:
- After suspension, all server operations are halted, and the server will not respond to incoming requests until it is resumed.
- After suspension, all server operations are halted, and the server will not respond to incoming requests until it is resumed.

## Resuming

Once you’ve completed any tasks or troubleshooting, you can resume the server using `Resume-PodeServer`. This will restore the Pode server to its normal operational state:

1. **Run the Resume Command**:
- Call `Resume-PodeServer` to bring the server back online.
- Call `Resume-PodeServer` to bring the server back online.

```powershell
Resume-PodeServer
```
```powershell
Resume-PodeServer
```
2. **Resumption Process**:
- When `Resume-PodeServer` is executed, Pode will:
- Restore all paused runspaces back to their active states.
- Trigger a "Resume" event, marking the server as active again.
- Clear the console, providing a refreshed view of the server status.
- When `Resume-PodeServer` is executed, Pode will:
- Restore all paused runspaces back to their active states.
- Trigger a "Resume" event, marking the server as active again.
- Clear the console, providing a refreshed view of the server status.
3. **Outcome**:
- The server resumes normal operations and can now handle incoming requests again.
- The server resumes normal operations and can now handle incoming requests again.
## When to Use Suspend and Resume
Expand Down
23 changes: 11 additions & 12 deletions src/Private/Console.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,20 @@ function Show-PodeConsoleInfo {
$status = $Podelocale.suspendingMessage
$statusColor = [System.ConsoleColor]::Yellow
$showHelp = $false
$noHeaderNewLine = $true
$noHeaderNewLine = $false
$ctrlH = $false
$footerSeparator = $false
$topSeparator = $true
$topSeparator = $false
$headerSeparator = $false
}
elseif ($serverState -eq [Pode.PodeServerState]::Resuming) {

$status = $Podelocale.resumingMessage
$statusColor = [System.ConsoleColor]::Yellow
$showHelp = $false
$noHeaderNewLine = $true
$noHeaderNewLine = $false
$ctrlH = $false
$footerSeparator = $false
$topSeparator = $true
$topSeparator = $false
$headerSeparator = $false
}
elseif ($serverState -eq [Pode.PodeServerState]::Restarting) {
Expand All @@ -82,17 +81,17 @@ function Show-PodeConsoleInfo {
$noHeaderNewLine = $false
$ctrlH = $false
$footerSeparator = $false
$topSeparator = $true
$topSeparator = $false
$headerSeparator = $false
}
elseif ($serverState -eq [Pode.PodeServerState]::Starting) {
$status = $Podelocale.startingMessage
$statusColor = [System.ConsoleColor]::Yellow
$showHelp = $false
$noHeaderNewLine = $true
$noHeaderNewLine = $false
$ctrlH = $false
$footerSeparator = $false
$topSeparator = $true
$topSeparator = $ShowTopSeparator.IsPresent
$headerSeparator = $false
}
elseif ($serverState -eq [Pode.PodeServerState]::Running) {
Expand All @@ -109,7 +108,7 @@ function Show-PodeConsoleInfo {
$status = $Podelocale.terminatingMessage
$statusColor = [System.ConsoleColor]::Red
$showHelp = $false
$noHeaderNewLine = $true
$noHeaderNewLine = $false
$ctrlH = $false
$footerSeparator = $false
$topSeparator = $false
Expand Down Expand Up @@ -1056,8 +1055,6 @@ function Invoke-PodeConsoleAction {
elseif ((Test-PodeKeyPressed -Key $Key -Character $KeyBindings.Disable)) {
# Handle enable/disable server actions
if ($PodeContext.Server.AllowedActions.Disable -and ($serverState -eq [Pode.PodeServerState]::Running)) {
# Write a horizontal divider line to the console.
Write-PodeHostDivider -Force $true
if (Test-PodeServerIsEnabled) {
Close-PodeCancellationTokenRequest -Type Disable
}
Expand All @@ -1066,6 +1063,7 @@ function Invoke-PodeConsoleAction {
}

Write-PodeConsoleHeader -DisableHttp

}
}
elseif ((Test-PodeKeyPressed -Key $Key -Character $KeyBindings.Suspend)) {
Expand Down Expand Up @@ -1428,7 +1426,8 @@ function Test-PodeHasConsole {
}
return ([Pode.NativeMethods]::IsTerminal($handleTypeMap.Input -and `
[Pode.NativeMethods]::IsTerminal($handleTypeMap.Output) -and `
[Pode.NativeMethods]::IsTerminal($handleTypeMap.Error))
[Pode.NativeMethods]::IsTerminal($handleTypeMap.Error)
)
)
}
return $false
Expand Down
2 changes: 1 addition & 1 deletion src/Private/Server.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Start-PodeInternalServer {
$null = Test-PodeVersionPwshEOL -ReportUntested

#Show starting console
Show-PodeConsoleInfo
Show-PodeConsoleInfo -ShowTopSeparator

# run start event hooks
Invoke-PodeEvent -Type Starting
Expand Down

0 comments on commit 34b367f

Please sign in to comment.