diff --git a/src/Private/Context.ps1 b/src/Private/Context.ps1 index a4f4f9d98..19d4c1004 100644 --- a/src/Private/Context.ps1 +++ b/src/Private/Context.ps1 @@ -53,7 +53,10 @@ function New-PodeContext { $IgnoreServerConfig, [string] - $ConfigFile + $ConfigFile, + + [switch] + $Daemon ) # set a random server name if one not supplied @@ -290,8 +293,8 @@ function New-PodeContext { # is the server running under Heroku? $ctx.Server.IsHeroku = (!$isServerless -and (!(Test-PodeIsEmpty $env:PORT)) -and (!(Test-PodeIsEmpty $env:DYNO))) - # Check if the current session is running in a console-like environment - if (Test-PodeHasConsole) { + # Check if the current session is running in a console-like environment and it's not marked as Daemon + if ((Test-PodeHasConsole) -and ! $Daemon) { try { if (! (Test-PodeIsISEHost)) { # If the session is not configured for quiet mode, modify console behavior @@ -311,14 +314,12 @@ function New-PodeContext { } } catch { - $_ | Write-PodeErrorLog # Console support is partial , configure the context for non-console behavior $ctx.Server.Console.DisableTermination = $true # Prevent termination $ctx.Server.Console.DisableConsoleInput = $true # Disable console input $ctx.Server.Console.Quiet = $true # Silence the console $ctx.Server.Console.ShowDivider = $false # Disable divider display } - } else { # If not running in a console-like environment, configure the context for non-console behavior @@ -1221,4 +1222,4 @@ function Set-PodeOutputVariable { $_ | Write-PodeErrorLog } } -} \ No newline at end of file +} diff --git a/src/Public/Core.ps1 b/src/Public/Core.ps1 index 5d7054bd7..ef83806eb 100644 --- a/src/Public/Core.ps1 +++ b/src/Public/Core.ps1 @@ -268,6 +268,7 @@ function Start-PodeServer { EnableBreakpoints = $EnableBreakpoints IgnoreServerConfig = $IgnoreServerConfig ConfigFile = $ConfigFile + Daemon = $Daemon }