Start PicoWeb Server, get pid and kill it later

0 votes
asked Aug 24, 2022 in Question / help by rkrug (420 points)
Hi

I have a problem with the server. I want to start the server in the background from R (which works) and kill it after I have generated a few graphs (which I do not manage).

The problem is to get the pid of the PicoWeb Server to kill it. Standard R functions do return the wrong one (one to low), or when the port is open, and I resort to using `ups -I` to list all Java processes, and to identify which one has been launched.

Now I am wondering - would it be possible to return in the server info the pid as well? It seems to be (please keep in mind I an NOT a programmer apart from R and definitely not Java) possible to get the pid from within the running java process (https://stackoverflow.com/a/42104000/632423). I have no idea how this could be included, but it would be great to have this.

Another possibility (probably cleaner) would be an endpoint which stops the PicoWeb Server (e.g. localhost:8000/stopserver).

Thanks,

Rainer

1 Answer

0 votes
answered Aug 24, 2022 by plantuml (294,960 points)
With last snapshot https://github.com/plantuml/plantuml/releases/tag/snapshot you can launch PicoWebServer this way:

java -jar plantuml.jar -picowebstop

This way, a call to localhost:8000/stopserver will stop the server.

Is this what you were expecting?
commented Aug 25, 2022 by rkrug (420 points)
Hm. I tried to open

`http://localhost:8000/stopserver` as well as

`http://localhost:8000/plantuml/stopserver` but it does not work - am I missing something?

It would also be great if this could return a value when successfully received the request to stop. Obviously, it can not send a response after the server has been shutdown.
commented Aug 25, 2022 by rkrug (420 points)

OK - got it working.

I have to call

`http://localhost:8000/stopserver`

and nothing happens.

I contact the server again, e.g. via

`http://localhost:8000/serverinfo`

and I get the info back and the server stops.

commented Aug 30, 2022 by rkrug (420 points)
Just tried Snapshot Version ~v1.2022.8beta3 of the 2022-08-29 at 17:04:29 (UTC) and it is working as expected - thanks a lot.

Will this be included in the next release?
commented Aug 30, 2022 by plantuml (294,960 points)

Will this be included in the next release?

Yes, in September.

Tell us if you have other ideas! :-)

commented Aug 31, 2022 by rkrug (420 points)
I think I am happy at the moment. Thanks.
...