Hi to all !
I’m developing a small application (pure javascript+html+css) to help administrate our containers.
I’ve found out how to execute a command via the REST api. This part works fine.
Here are the parameters I POST to https://lxd-server:8443/1.0/containers/container/exec :
As one can read, the command is a “tail -f /var/log/apache2/access.log”.
After this is POSTed to the convenient url, I get the file descriptors and operate mainly on stdin through a websocket opened on the correct url.
This again works fine and I have the display behave correctly.
This said, what would the best way to stop the so-launched remote command ?
Send a DELETE on the operation ?
Destroy the websocket (I’m not sure this would do anything but kill the display process) ?
Some other thing I can’t think of ?
Thanks to anyone who can help me or direct me towards some solution to my problem.
Regards.
The control websocket allows for sending signals to the process, you can use that to send a SIGTERM or SIGKILL.
A DELETE of the operation won’t work as I don’t believe this particular operation has a canceler setup.
Alternative would be to start another command which kills the tail command from inside the container, but it feels like using the control socket is likely the best option.