Jump to content
Sign in to follow this  
LLuca

FMXLinux web app deployment

Recommended Posts

Hello everyone, first of all I'm glad to have find out about this great forum and community.

I need to ask you a question about the recent integration of rad studio: FMXLinux.

 

I've successfully completed all the steps about installing and running FireMonkey for Linux.

I've been able to set GTK backend with broadway and to run my sample application on localhost:8080.

 

Now I would like to deploy a web application on my web domain (linux hosting) and I was thinking about writing a php script able to execute the x-executable.

Considering that I don't know much about GTK, am I doing the right thing?

if not, how can I deploy a FMXLinux app as a web app on a web domain?

 

Thank you for your time

 

Share this post


Link to post

The way broadwayd appears to work is that it runs a single application on a single port for a single user. The connection is persistent because it is a websocket. This means that you need 1 port set up per concurrent user. 

 

I came up with some code but it isn't quite right yet. Basically, you have to run broadwayd and the app in the background. I came with this for loop bash script (edit: works now). Make sure you have enough RAM.

 

#!/bin/bash
for i in {1..99}
do
    nohup broadwayd :$i &
    export GDK_BACKEND=broadway
    export BROADWAY_DISPLAY=:$i
    ./FireMonkeyPaintDemo &
done
 

Once you get your application running on 100 ports in the background (which will support 100 simultaneous connections/users) then you need a TCP load balancer to turn the 100 points into 1 port. One such tool is HAProxy:

 

https://www.haproxy.com/blog/websockets-load-balancing-with-haproxy/

 

A simpler tool (with maybe less performance) is called balance (sudo apt install balance ). 

 

https://www.systutorials.com/docs/linux/man/1-balance/

 

Here is a sample command which would load balance 4 broadwayd ports as port 81:

 

balance 81 localhost:8080 localhost:8081 localhost:8082 localhost:8083
 

After running this and the above you would be able to connect to localhost:81 and it will load balance you across the 4 backend ports.

 

You can probably also do this with TIdMappedPortTCP.

Edited by Eli M.
  • Like 1

Share this post


Link to post

Thank you for your answer. As soon as I can apply your suggestions I'll update this post.

Share this post


Link to post

Updated version. Takes two params. First is the path of the app to run and the second is the port to run it on. Apparently balance only supports 16 (or 32) groups unless you compile it yourself.

 

Example:

./gtkcloud.sh /root/FireMonkeyPaintDemo 81

 

#!/bin/bash
for i in {1..16}
do
    nohup broadwayd :$i &
    export GDK_BACKEND=broadway
    export BROADWAY_DISPLAY=:$i
    $1 &
    #echo ""
done

servers=""

for ii in {1..18}
do
    let port=8080+$ii
    servers="$servers localhost:$port:1 %"
done

echo $servers

balance $2 $servers

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×