Recent

Author Topic: [SOLVED] How to make a permanent server and/or cgi application ?  (Read 1437 times)

tintinux

  • Sr. Member
  • ****
  • Posts: 373
    • Gestinux
Hi

I'd like to move a standalone application to the web.

Currenty it works fine like this :

  • Input a genealogy filename (.ged), read the file and interpret it to a rather complex structure in memory  (with trees and dynamic arrays of objets)
  • Input search criteria and search data in some fields in the memory structure and display the corresponding persons
  • Allow replacements in the dataSearch of some data in the structure

No database is used.

The 1st step can be long, and searches and replacements can use the results of the previous search, Thus, I allow users to run once the 1st step, and several times the others.

No problem with the standalone GUI application, but how can I achieve that on the web ?

I can make a cgi application (with fpweb), but the memory is initialized on each request, and I don't know how to share memory between the different requests .

I think I need a permanent application running on the web server, receiving data from a cgi-application, and sending it to it. The cgi application process inputs from a web page and display results.   

What is the simpler way to achieve that ?   

Thanks for your hints !






« Last Edit: September 09, 2025, 09:04:41 am by tintinux »
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

n7800

  • Hero Member
  • *****
  • Posts: 547
  • Lazarus IDE contributor
    • GitLab profile
Re: How to make a permanent server and/or cgi application ?
« Reply #1 on: August 29, 2025, 05:04:32 pm »
If you need to interact with a "share" running application, then you need IPC. The specific implementation is a huge number of options...

By the way, one of its options is a socket.

suve

  • Newbie
  • Posts: 6
Re: How to make a permanent server and/or cgi application ?
« Reply #2 on: September 02, 2025, 05:49:07 pm »
Another solution you could use is to have a HTTP server built into your application. Then, you either expose the application directory, or configure your HTTP server to act as a proxy and pass the requests along.

Thaddy

  • Hero Member
  • *****
  • Posts: 18325
  • Here stood a man who saw the Elbe and jumped it.
Re: How to make a permanent server and/or cgi application ?
« Reply #3 on: September 03, 2025, 06:55:21 am »
Replace cgi with fastcgi. Fastcgi does not initialize per connection. Whereas cgi starts a new process per connection, fastcgi uses just one and the same process for all connections. (or a limit, configurable on the server)
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

tintinux

  • Sr. Member
  • ****
  • Posts: 373
    • Gestinux
Re: How to make a permanent server and/or cgi application ?
« Reply #4 on: September 03, 2025, 11:30:31 am »
Replace cgi with fastcgi. Fastcgi does not initialize per connection. Whereas cgi starts a new process per connection, fastcgi uses just one and the same process for all connections. (or a limit, configurable on the server)
Ah, thanks !
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

Thaddy

  • Hero Member
  • *****
  • Posts: 18325
  • Here stood a man who saw the Elbe and jumped it.
Re: How to make a permanent server and/or cgi application ?
« Reply #5 on: September 03, 2025, 03:06:49 pm »
Mind you, using fastcgi comes with responsabilities. Where cgi, because of its stateless nature, will not cause a system to break down if one instance fails, fastcgi will break down all connections attached to it. You have to be a bit more careful in programming fastcgi to get it right and safe. But it scales much better than cgi so it is worth the effort.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

tintinux

  • Sr. Member
  • ****
  • Posts: 373
    • Gestinux
Re: How to make a permanent server and/or cgi application ?
« Reply #6 on: September 09, 2025, 09:05:40 am »
Mind you, using fastcgi comes with responsabilities. Where cgi, because of its stateless nature, will not cause a system to break down if one instance fails, fastcgi will break down all connections attached to it. You have to be a bit more careful in programming fastcgi to get it right and safe. But it scales much better than cgi so it is worth the effort.
Yes, you are right !
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8831
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [SOLVED] How to make a permanent server and/or cgi application ?
« Reply #7 on: September 11, 2025, 02:42:45 pm »
No database is used.
...
I can make a cgi application (with fpweb), but the memory is initialized on each request, and I don't know how to share memory between the different requests .
...
What is the simpler way to achieve that ?   
Options:
  • Use a database
  • Use something else that can act as a replacement for database, like files
  • Let the CGI only act as a front gate, the one actually doing the hard job is a long running process, can use IPC, pipes, (in-memory) databases (Memcache, Redis / ValKey, etc.), anything. You have plenty of options available

 

TinyPortal © 2005-2018