Pode icon indicating copy to clipboard operation
Pode copied to clipboard

Add -AsJob switch to Start-PodeServer

Open Badgerati opened this issue 5 years ago • 0 comments

Describe the Change

This one comes off the back of #546. While setting up the tests, I found you could run Pode using Start-Job. This could make it possible to add an -AsJob switch onto Start-PodeServer 🤔

If it works, Pode already has some internal server naming system - so we could start a job with that name and then Start-PodeServer returns just the name. Meaning you can use Receive-Job/Stop-Job etc.

The one thing I couldn't work out was a clean way to kill the server on Stop-Job, without it hanging for 5mins and then forcibly killing the job. The only way I found was to have a /close endpoint that uses Close-PodeServer; you can call that endpoint and then call Stop-Job. If a more ideal solution can be found, then a Stop-PodeServer could be implemented.

On top of this, docs for -AsJob can be written up (as a host?), or write up how to use Start-Job as a wrapper around Start-PodeServer.

Related Issues

Issue #546

Badgerati avatar May 10 '20 11:05 Badgerati