-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pode Watchdog Feature (work in progress) #1416
base: develop
Are you sure you want to change the base?
Conversation
@@ -40,7 +40,6 @@ | |||
function Add-PodeRunspace { | |||
param( | |||
[Parameter(Mandatory = $true)] | |||
[ValidateSet('Main', 'Signals', 'Schedules', 'Gui', 'Web', 'Smtp', 'Tcp', 'Tasks', 'WebSockets', 'Files', 'Timers')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this type of validation? This feels like a good case for Enums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line will go away with the asyncrout #1349
# If the object is neither a hashtable, ordered dictionary, nor array, return it as-is | ||
return $InputObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we should always cast to ConvertTo-PodeConcurrentStrucutre
? That may reduce the cognitive overhead and just assume that we always cast. Maybe add another check at the top to return something that's already been cast to keep the cost low.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created this function primarly for #1391 (PodeState threadsafe)
The reason of this function is to convert any hashtable or array that has to be thread safe to as safe-thread object
System.Collections.Concurrent.ConcurrentDictionary for hashtable and System.Collections for array.
It's not meant to be used for any hashtable or array
src/Private/Watchdog.ps1
Outdated
function Set-PodeWatchdogHearthbeatStatus { | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateSet('Starting', 'Restarting', 'Running', 'Undefined', 'Stopping', 'Stopped', 'Offline')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another place I think it would be helpful to have enums and maybe a watchdog class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll try with Enum. But normally are a pain in poweshell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually have an Enum folder and with a .ps1
which I dot load or toss at the top when the module is compiled. If it's a function that's only ever used by internal developers then it may not be worth the hassle.
Co-authored-by: Gilbert Sanchez <[email protected]>
cleanup monitor data sent by the client
set timeout to Restart-PodeWatchdogMonitoredProcess
for linux compatibility
Summary
This pull request introduces the Pode Watchdog feature, which allows users to monitor and manage processes or scripts running within their Pode server. The Watchdog automatically tracks process status and uptime, monitors file changes, and provides API endpoints for interacting with the monitored processes. Key functionalities include process monitoring, automatic restarts, session management during restarts/shutdowns, and remote control through REST APIs.
Key Features
NamedPipeStream
.$RestartServiceAfter
) before attempting to restart the process. The process can be restarted a maximum of$MaxNumberOfRestarts
times. The restart counter is reset after a successful run of$ResetFailCountAfter
minutes.Usage Example
This feature allows users to set up and monitor a process with a Pode server and interact with the process via REST API routes. Below is a sample setup:
Documentation
Full documentation for the Pode Watchdog feature has been included, covering:
This feature needs #1387 to be complete