Powershell: start and stop flask server
I wrote a powershell script to start my flask server, run my tests then stop my server. It starts the server and runs my tests. However, when it kills the $server process, it leaves the actual server process running and I can see the window for this process still open. How can I kill the server after the tests finish running?
$db_id = [guid]::NewGuid().ToString()
$env:AUTHZ_DB_FILE = 'Authorization ' + $db_id
$server = Start-Process py -ArgumentList '-m', 'authz.test.server' -PassThru
Write-Output $server.Id
py -m authz.test.tests $args
Stop-Process -Id $server.Id
Try
Stop-Process -Id $server.Id -Force