Launch Unity api server (before login)

Feature requests / 3rd party software development
Post Reply
vland
Posts: 4
Joined: Thu May 04, 2023 5:58 pm

Launch Unity api server (before login)

Post by vland »

Hi,

I'd like to remotely startup my astro pc and automatically launch Unity server "as a windows service"
in this way I would be able to do everything: turn on/off stuff, read temperature, turn on/off autodew etc. etc even before logging into windows remote desktop.

is there a way to do this?
I feel that the benefit of a full REST API server is to be "detached" from the windows UI.... but there must be a way to start the server! :)

thanks

(of course if I login into windows it is easy, I can simply put Peg.UI.exe inside "win + R" > shell:startup :roll:
User avatar
Evans
Site Admin
Posts: 504
Joined: Wed Dec 02, 2020 3:06 pm
Contact:

Re: Launch Unity api server (before login)

Post by Evans »

It is something we are thinking also but we haven't implemented it as a service.
However, you can launch only the server from the program files and have it in the background.
vland
Posts: 4
Joined: Thu May 04, 2023 5:58 pm

Re: Launch Unity api server (before login)

Post by vland »

ok thanks... this is what I'm doing atm, if anyone's interested

1) start Peg.Server.exe executable
2) API call /Server/Start
3) API call /Driver/UPBv2/Start?DriverUniqueKey={guid}

in this way I can give commands without UI.
I do this from telegram bot but could be from a batch file or whatever

PS: I warmly suggest to make the UI lighter... the previous version was simple and fast.
This new UI has movable/savable panels and advanced graphics and all is nice BUT is also very slow.
Remember a lot of us are using this stuff from mini-PCs
There is a serious memory leak if the UI "Device View" (eg upbv2) is kept open for hours/days. The solution is to close device view and open it again
airscottdenning
Posts: 3
Joined: Sun Jul 02, 2023 2:30 pm

Re: Launch Unity api server (before login)

Post by airscottdenning »

I'm trying to use something similar to control my Pocket PowerBox Advance via CMD or python scripts.

I can't get the server to return the UniqueKey using the REST API. So I'm stuck.

Here's my http: request using curl and the response:

C:\Users\airsc>curl -v http://localhost:32000/Server/Start
* Trying 127.0.0.1:32000...
* Connected to localhost (127.0.0.1) port 32000 (#0)
> GET /Server/Start HTTP/1.1
> Host: localhost:32000
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 405 Method Not Allowed
< Date: Sun, 02 Jul 2023 17:05:09 GMT
< Server: Kestrel
< Content-Length: 0
< Allow: PUT
<
* Connection #0 to host localhost left intact

Similarly, I get no indication of the UniqueKey for the device ("data" is empty) using this request:

C:\Users\airsc>curl http://localhost:32000/Reporting/Device
{"status":"success","code":200,"message":"Devices with available report.","data":[]}
C:\Users\airsc>

What am I doing wrong?
vland
Posts: 4
Joined: Thu May 04, 2023 5:58 pm

Re: Launch Unity api server (before login)

Post by vland »

airscottdenning wrote: Sun Jul 02, 2023 5:09 pm I'm trying to use something similar to control my Pocket PowerBox Advance via CMD or python scripts.

I can't get the server to return the UniqueKey using the REST API. So I'm stuck.

Here's my http: request using curl and the response:

C:\Users\airsc>curl -v http://localhost:32000/Server/Start
* Trying 127.0.0.1:32000...
* Connected to localhost (127.0.0.1) port 32000 (#0)
> GET /Server/Start HTTP/1.1
> Host: localhost:32000
> User-Agent: curl/8.0.1
> Accept: */*
>
< HTTP/1.1 405 Method Not Allowed
< Date: Sun, 02 Jul 2023 17:05:09 GMT
< Server: Kestrel
< Content-Length: 0
< Allow: PUT
<
* Connection #0 to host localhost left intact

Similarly, I get no indication of the UniqueKey for the device ("data" is empty) using this request:

C:\Users\airsc>curl http://localhost:32000/Reporting/Device
{"status":"success","code":200,"message":"Devices with available report.","data":[]}
C:\Users\airsc>

What am I doing wrong?
I guess you solved by now... anyway you are doing a GET request, that's wrong.
try with the correct method PUT
Post Reply