Recent

Author Topic: Brook Framework issue and Lazarus 1.6  (Read 8158 times)

snorkel

  • Hero Member
  • *****
  • Posts: 817
Brook Framework issue and Lazarus 1.6
« on: August 25, 2016, 09:20:16 pm »
I had to recompile a brook app that has sat for a long time.
I installed the brook package and the values var did not work the same.

Kept giving me errors
unit1.pas(40,31) Error: Incompatible type for arg no. 1: Got "Constant String", expected "LongInt"
when the original code was:

coid:=Values.['coid'].asstring;

had to change it to:

coid:=Values.values['coid'];

when I run the brook cgi from the command line it just hangs and does not work on the web browser where the original compiled cgi was from a couple of years ago.

Is there a different version I should be using for FPC 3.0 and Laz 1.6?  I Just downloaded the latest release from the brook site.

When I orginally compiled this brook cgi, you could call it from command line and it would out put some text, but now on FPC 3.0 and Laz 1.6 this test just hangs.

Anyone have any suggestions on how to get my old brook code working?



***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Brook Framework issue and Lazarus 1.6
« Reply #1 on: August 26, 2016, 04:07:20 am »
Brook 3 introduced some backward incompatible changes a while ago, not really remember which version / commit. Some in-house data structures are reverted to use what's available in FPC.

Executing CGI on command line shouldn't hang, at least in should only raise exceptions. CGI programs are pure console programs. It must be something else you must debug.

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Brook Framework issue and Lazarus 1.6
« Reply #2 on: August 26, 2016, 07:09:49 pm »
Yep, the original version I did a couple years ago would out put some text from the command line when I would run them like:
./cgi_test

I also tried the simple demos with brook 3 and they also hung when run from the command line.
I am running the 64bit version of Lazarus and FPC on Kubuntu, not sure if that would matter.

***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Brook Framework issue and Lazarus 1.6
« Reply #3 on: August 26, 2016, 08:03:46 pm »
I'm on the same x86_64-linux system (but not Kubuntu) and the CGI works perfectly:
Code: [Select]
$ cat coba.pas
{$mode objfpc}

uses
  BrookFCLCGIBroker,BrookApplication,BrookAction;
type
  THelloAction = class(TBrookAction)
    procedure Get; override;
  end;

procedure THelloAction.Get;
begin
  Write('Hello, World!');
end;

begin
  THelloAction.Register('*');
  BrookApp.Run;
end.

$ ./coba
X-Powered-By: Brook framework and FCL-Web.
Status: 500 Internal Server Error
Content-Length: 177
Content-Type: text/html; charset=utf-8

<html><head><title>Internal server error</title></head><body><h1>500 - Internal server error</h1><p style="color: red;" >No REQUEST_METHOD passed from server.</p></body></html>
$ REQUEST_METHOD=GET ./coba
X-Powered-By: Brook framework and FCL-Web.
Status: 200 OK
Content-Length: 14
Content-Type: text/html; charset=utf-8

Hello, World!

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Brook Framework issue and Lazarus 1.6
« Reply #4 on: August 26, 2016, 08:18:41 pm »
Your example hangs on my system as well.....grrrrr.
Not sure what the heck is going on.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Brook Framework issue and Lazarus 1.6
« Reply #5 on: August 26, 2016, 08:37:25 pm »
I am going to try and compile the app on my windows system and see if I get the same results.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Brook Framework issue and Lazarus 1.6
« Reply #6 on: August 26, 2016, 09:01:26 pm »
same exact behavior on windows 32 bit with the release version of brook.
Just hangs on BrookApp.Run;

All the cgi demo apps hang as well as the example you posted.

***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Brook Framework issue and Lazarus 1.6
« Reply #7 on: August 26, 2016, 09:52:07 pm »
well, I take that back about it being the same on windows.
On windows it hangs when I run it from the command line, but if I hit CTRL+C I then get some output back.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Brook Framework issue and Lazarus 1.6
« Reply #8 on: August 26, 2016, 10:28:32 pm »
ok, in case anyone wants to know I got it working.
For whatever reason I need to add cthreads to the uses in the project source.
only way I found out was by using the Apache web server long to see the error that was logged and it mentioned something about a missing thread library.

Anyways works now and I am using the git master version.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Brook Framework issue and Lazarus 1.6
« Reply #9 on: August 27, 2016, 07:06:56 am »
OK, that's interestingly weird. There should be no requirement for that unless you use embedded HTTP server and set its Threaded property to true. Even if you forget to do so you should still get:
Code: [Select]
$ cat coba.pas
{$mode objfpc}

uses
  BrookFCLHTTPAppBroker,BrookUtils,BrookApplication,BrookAction;
type
  THelloAction = class(TBrookAction)
    procedure Get; override;
  end;

procedure THelloAction.Get;
begin
  Write('Hello, World!');
end;

begin
  THelloAction.Register('*');
  BrookSettings.Port := 2345;
  (BrookApp.Instance as TBrookHTTPApplication).Threaded := true;
  BrookApp.Run;
end.
$ ./coba
Open the 'http://localhost:2345' URL in your browser.

Use [Ctrl+C] to quit ...
This binary has no thread support compiled in.
Recompile the application with a thread-driver in the program uses clause before other units using thread.
Runtime error 232 at $00000000004192BD
  $00000000004192BD
  $00000000004469C6
  $00000000004006C8
  $00000000004004DD
Let's just assume every system is unique (though that doesn't sound logically correct).

 

TinyPortal © 2005-2018