jpsider / RestPS

Simple ReST Framework for Powershell
MIT License
112 stars 30 forks source link

restapi as a windows service #38

Closed Lichtsinnig closed 4 years ago

Lichtsinnig commented 4 years ago

How do I run restapi as a windows service?

jpsider commented 4 years ago

That is not something that is handled by the PowerShell Module.

You would need to do something like this: https://4sysops.com/archives/how-to-run-a-powershell-script-as-a-windows-service/ or more complicated: https://docs.microsoft.com/en-us/archive/msdn-magazine/2016/may/windows-powershell-writing-windows-services-in-powershell

joel74 commented 4 years ago

I use the service manager program (ssm.exe) included in SaltStack to do this: cmd /c c:\salt\bin\ssm.exe install {service name} Powershell.exe {path to listener script}\Invoke-RestPSListener.ps1 -RoutesFilePath {path to routes script}\RestPS_Endpoints\Invoke-AvailableRouteSet.ps1 -Port 8081

ssm.exe includes a number of config flags, to set logging, restart options, run as user, etc. I can't locate the documentation at the moment, though.

jpsider commented 4 years ago

Thanks @joel74 !!