From 1b7768d289f80e4507c907b4ad593ba88a112fe4 Mon Sep 17 00:00:00 2001 From: mdaneri Date: Mon, 3 Mar 2025 18:18:42 -0800 Subject: [PATCH 1/2] Implement #1514 #1514 --- src/Private/Context.ps1 | 11 ++++++----- src/Public/Core.ps1 | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Private/Context.ps1 b/src/Private/Context.ps1 index a4f4f9d98..eb487606f 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 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 } From 1e834fe526abff8168af1fee1b2fe37061e3fa01 Mon Sep 17 00:00:00 2001 From: mdaneri <17148649+mdaneri@users.noreply.github.com> Date: Mon, 10 Mar 2025 20:15:32 -0700 Subject: [PATCH 2/2] Update Context.ps1 --- src/Private/Context.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Private/Context.ps1 b/src/Private/Context.ps1 index eb487606f..19d4c1004 100644 --- a/src/Private/Context.ps1 +++ b/src/Private/Context.ps1 @@ -294,7 +294,7 @@ function New-PodeContext { $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 and it's not marked as Daemon - if (Test-PodeHasConsole -and ! $Daemon) { + if ((Test-PodeHasConsole) -and ! $Daemon) { try { if (! (Test-PodeIsISEHost)) { # If the session is not configured for quiet mode, modify console behavior @@ -1222,4 +1222,4 @@ function Set-PodeOutputVariable { $_ | Write-PodeErrorLog } } -} \ No newline at end of file +}