Recent

Author Topic: Micro-services through LAMP  (Read 4598 times)

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Micro-services through LAMP
« on: February 07, 2017, 11:09:48 am »
I have some hosting providers that use cloudlinux (a limited Red Hat) and I want to run some Free Pascal micro-services.

What is the simplest way to execute them (probably through PHP) and is it possible to have my executable handle the connection, or does all the communication have to go through Apache / PHP?

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Micro-services through LAMP
« Reply #1 on: February 07, 2017, 12:21:03 pm »
In principle (but depending on the provider's definition of micro-services) you should be able to install fpc applications on your server as stand-alone providers.
I even have fpc itself running on a webserver. Some others too.
Note that advice against running Lazarus applications because they are probably not really "micro".
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Micro-services through LAMP
« Reply #2 on: February 07, 2017, 12:36:32 pm »
Client connects to server -> Apache loads page from disk -> page is index.php, Apache starts php and gives it index.php as parameter -> php executes 'echo `~/myapplication`;' and redirects output to Apache -> Apache sends it back to client and disconnects.

I would like 'myapplication' to handle the connection as much as possible. And I would like to have the option to keep some of them connected.


As for free pascal apps not being micro: most micro-services are actually VMs running a LAMP or IIS/ASP.NET server...

I rather run a set of executables that listen on different ports, but that requires a dedicated server (or at least root access). So I'll settle on one or more executables to handle the requests, like http://myserver.com/service1/params .. http://myserver.com/serviceN/params .

It beats using PHP :)

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Micro-services through LAMP
« Reply #3 on: February 07, 2017, 12:44:46 pm »
I understood your question as by-passing lamp and let all the work do by fpc.
That can be done.
And lamp accepts all cgi, fastcgi, etc, take your pick.

Still not clear to me...
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Micro-services through LAMP
« Reply #4 on: February 07, 2017, 12:57:45 pm »
So, what do I have to do and how would my URL look like to get that to work? I have no idea.

I have no root access, no yum etc. CGI should work (Perl is installed as well).

This is one of the first times I'm just a simple user.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Micro-services through LAMP
« Reply #5 on: February 07, 2017, 01:30:35 pm »
PHP has exec() if you insist on reimplementing CGI on top of PHP. Never use cloudlinux so I don't know if they allow native executables or not. If they do, consider taking pure FPC standalone service instead. It can run continuously, unlike PHP which must build everything from scratch on every request, at best only use caching engine to reduce the work. Simply configure your app to listen on any open port and access that from your browser. Must consult provider on this, but port 80 should open, otherwise they can't serve HTTP normally. Otherwise, both apache and nginx supports reverse proxy, so your app can listen on any port and web server will pass the request to your app if some conditions match (file extension, server name, whatever, you have plenty of options). You will need to write the virtual server config, but again, I don't know if your provider allows it or not as it's not a VPS where you have 100% full control of your own instances.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Micro-services through LAMP
« Reply #6 on: February 07, 2017, 01:55:45 pm »
"php -r 'echo `ls -al`;'" works, and while I can change the php configuration and copy files in my home dir (or a subdir), that's about it. Perl is installed, so I expect something like "http://myserver.com/cgi-bin/index.pl?params" to work as well. Apache listens on port 80 (I assume, no 'netstat' available).

AFAIK, to install software that listens on a port I need root access, and it has to be routed. So I assume (but I might be wrong) that I have to use port 80 and Apache.

In the FCGI (FastCGI) sticky is a long explanation on how to install the required modules and change the configuration, both of which I don't seem to be able to do. (I cannot even find the apache2 / httpd config file.)

Cloudlinux.com talks quite a bit about "limiting abusers" and preventing such users to change things, so I expect that to be as intended.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Micro-services through LAMP
« Reply #7 on: February 07, 2017, 03:56:10 pm »
Cloudlinux.com talks quite a bit about "limiting abusers" and preventing such users to change things, so I expect that to be as intended.

If you're struggling with your provider, then maybe change providers? Here's a real provider, free for a year, Linux or Windows your choice (and instructions on how to set it up):

https://macpgmr.github.io/MacXPlatform/PascalDynLibs_4.html

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Micro-services through LAMP
« Reply #8 on: February 07, 2017, 04:09:01 pm »
Very nice. Thanks.

It's for a complicated demo, and those were the ones I use for some personal sites. But I rather use Amazon, of course.

 

TinyPortal © 2005-2018