Forum

Author Topic: Allow agisoft-license-server deactivation while still running the server  (Read 735 times)

baal

  • Newbie
  • *
  • Posts: 2
    • View Profile
We are currently running the agisoft-fls (agisoft-license-server) in a containerized environment and activate a license and start the server like this:

Code: [Select]
# activate key
./agisoft-fls --activate $ACTIVATION_KEY
# start agisoft floating license server in background
./agisoft-fls --host 0.0.0.0:5842 &

When any problem occurs and the container is terminated we would love to use some sort of lifecycle prestop hook with a command like this:

Code: [Select]
/agisoft-license-server/agisoft-fls --deactivate metashape-pro

But this only yields
Quote
Server is already running on this machine
.

Stopping the agisoft-fls process (e.g.
Code: [Select]
pkill agisoft-fls) will not work as this will instantly terminate the running container as agisoft-fls is the init process and will not deactivate the license correctly.
Is there any way to make it possible to deactivate the license with a running agisoft-fls in the background?
Why is activating the license and starting the server a separate task? It would also be nice to activate the license after the server has started (or using --host and --activate in one command)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15138
    • View Profile
Re: Allow agisoft-license-server deactivation while still running the server
« Reply #1 on: October 15, 2024, 04:11:15 PM »
Hello baal,

Currently, the only way to deactivate a license with the FLS running in the background is to communicate with the FLS via HTTP requests, as you normally do in the web browser but now in the command-line, e.g. with curl:
Code: [Select]
curl -c fls_cookies.txt -d "user_name=<username>&user_password=<password>" <host>:<port>/login.html
curl -b fls_cookies.txt -d "action=Deactivate&product=metashape-pro&confirmation=Yes" <host>:<port>/deactivate.html

Here cookies are stored in fls_cookies.txt, but they can also be stored in a variable:
Code: [Select]
cookies=$(curl -c - -d "user_name=<username>&user_password=<password>" <host>:<port>/login.html)
echo "${cookies}" | curl -b - -d "action=Deactivate&product=metashape-pro&confirmation=Yes" <host>:<port>/deactivate.html

Or, if your curl supports "--next" option, you can try a single command with no cookies file:

Code: [Select]
curl -b "" -d "user_name=<username>&user_password=<password>" <host>:<port>/login.html --next -b "" -d "action=Deactivate&product=metashape-pro&confirmation=Yes" <host>:<port>/deactivate.html
Please note:
1. FLS requires login, so two requests are needed and use cookies. <username> and <password> should be url-encoded, i.e. a whitespace is replaced with '+' and so on.
2. <host>:<port> should be one of the FLS addresses displayed on its "Help" page, not "0.0.0.0".
3. Request parameters may change in future versions, so these commands may require adjustment after FLS updates.


The activation and starting the server are separated, because the license is activated once (or very rarely), whereas the server can be re-started many times.
Best regards,
Alexey Pasumansky,
Agisoft LLC

baal

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Allow agisoft-license-server deactivation while still running the server
« Reply #2 on: October 16, 2024, 03:43:34 PM »
Thank you very much, that helped a lot!

We were able to use this apporach to start a deactivation while the server was still running.