ironmansoftware / universal-automation

Universal Automation is the PowerShell-first automation platform.
https://ironmansoftware.com/universal-automation/
MIT License
24 stars 4 forks source link

How to recover from crash #12

Closed PorreKaj closed 4 years ago

PorreKaj commented 4 years ago

Describe the Issue

MY VSCode terminal crashed, and now i'm unable to STOP, or CONNECT to the UA server,

Closing the powershell console running UA, and starting anew also does not work - I expect that deleting $Env:LocalAppData\UniversalAutomation would do the trick, but i'd rather not lose the scripts in there.

PS C:\Users\admreh> Stop-UAServer
You cannot call a method on a null-valued expression.
At C:\Users\admreh\Documents\WindowsPowerShell\Modules\UniversalAutomation\UniversalAutomation.psm1:75 char:5
+     $Script:UAServer.Kill()
+     ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Connect-UAServer -ComputerName "http://localhost:10000" -AppToken $AppToken.Token
Grant-UAAppToken : Call failed with status code 401 (Unauthorized): POST http://localhost:10000/api/v1/AppToken
At line:1 char:13
+ $AppToken = Grant-UAAppToken -Identity System -Role Administrator -Co ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Grant-UAAppToken], FlurlHttpException
    + FullyQualifiedErrorId : Flurl.Http.FlurlHttpException,UniversalAutomation.GrantAppTokenCommand

To Reproduce

Steps to reproduce the behavior: (Example)

  1. Click on the Hamburger
  2. Press ALT-F4
  3. Browser Closes...

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Script Sample

Attempt to attach sample code that will allow others to reproduce the issue. NOTE: Generally speaking this is the MOST EFFECTIVE way to have your issue resolved.

Version Information

adamdriscoll commented 4 years ago

Hmmm this is a good question. The problem with Connect is that it expects the configured appToken to be used. If you don't use appTokens, you shouldnt have to specify it because the sever will just allow you to connect without authentication.

If you are using AppTokens, you need to save that AppToken to connect again. That said, we need to have a way to recover an appToken. When you start the UA server with Start-UAServer, it will return an appToken if one is defined so that's one way to recover an appToken. That said, it almost seems like we need a different way to recover the appToken.

Stop-UAServer just stops the UA process. Honestly, it's probably implemented poorly because it just kills the process. It should issue a graceful shutdown command so we don't have database issues. I'll look at implementing that.

adamdriscoll commented 4 years ago

I'll work on the docs for this but I've implemented a graceful shutdown for Stop-UAServer. It will request a shutdown of the UA server and allow any jobs to complete before terminating the process. There is also now a -Force parameter to allow for immediately killing the process.

adamdriscoll commented 4 years ago

The server does this now. Especially since you don't need to manage app tokens directly if you don't need to. If something isn't clear on either the docs or with the product, please let me know.