borni69
Members-
Content Count
54 -
Joined
-
Last visited
Community Reputation
1 NeutralRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
WEB Standalone console APP “Indy http” in production ?
borni69 replied to borni69's topic in Network, Cloud and Web
deleted... -
Not sure if you figured it out, but the code below is working for me. And for me I see a diff from your code in RESTClient1.HandleRedirects:=true; RESTRequest1.Method :=TRESTRequestMethod.rmPOST; endpoint := 'https://something/'; content_type := 'application/json'; // ++ some toher params RESTClient1 := TRESTClient.Create(nil); RESTRequest1 := TRESTRequest.Create(nil); RESTResponse1 := TRESTResponse.Create(nil); try RESTRequest1.Client := RESTClient1; RESTRequest1.Response := RESTResponse1; RESTClient1.BaseURL:=endpoint; RESTClient1.HandleRedirects:=true; RESTRequest1.Method :=TRESTRequestMethod.rmPOST; RestRequest1.Params.Clear; RestRequest1.Params.AddItem('content-type', content_type ,pkHTTPHEADER,[poDoNotEncode] ); RestRequest1.Params.AddItem('x-amz-Date', amzdate ,pkHTTPHEADER ); RestRequest1.Params.AddItem('Authorization',authorization_header ,pkHTTPHEADER ,[poDoNotEncode]); RestRequest1.Params.AddItem('x-amz-content-sha256', payload_hash ,pkHTTPHEADER ,[poDoNotEncode] ); RestRequest1.AddBody(request_parameters , TRESTContentType.ctAPPLICATION_JSON ); try RESTRequest1.Execute; writeln('respons'); writeln( RESTResponse1.Content); except On E: Exception do writeln( e.Message); end; finally RESTClient1.Free; RESTRequest1.Free; RESTResponse1.Free; end; But I also set the body Json using system.json unit Jrequest_parameters := TjsonObject.Create; try Jrequest_parameters.AddPair(TJSONString.Create('fromhost'),TJSONString.Create('10.211.55.2')); Jrequest_parameters.AddPair(TJSONString.Create('fromport'),TJSONString.Create('3306')); Jrequest_parameters.AddPair(TJSONString.Create('fromschema'),TJSONString.Create('atest')); Jrequest_parameters.AddPair(TJSONString.Create('frompass'),TJSONString.Create('xxxxx')); Jrequest_parameters.AddPair(TJSONString.Create('tohost'),TJSONString.Create('10.211.55.2')); Jrequest_parameters.AddPair(TJSONString.Create('toport'),TJSONString.Create('3306')); Jrequest_parameters.AddPair(TJSONString.Create('toschema'),TJSONString.Create('atest2')); Jrequest_parameters.AddPair(TJSONString.Create('topass'),TJSONString.Create('xxxxx')); Jrequest_parameters.AddPair(TJSONString.Create('table'),TJSONString.Create('hseq_crm')); Jrequest_parameters.AddPair(TJSONString.Create('copylogs'),TJSONString.Create('0')); request_parameters := Jrequest_parameters.ToString; finally Jrequest_parameters.Free; end;
-
Not sure I understand you, but I make a lot of curl command from my web app running on linux.. Example converting heic to jpg I do this with curl command from Delphi on Linux ubuntu.. process 1) image uploadet from web in .heic format 2) save to disc 3) curl convert heic to jpg using converter installed on linux 4) load .jpg from disc 5) delete on disc 6) upload to s3 If you need something like this I can give you an example.. but maybe I am misunderstanding what you are looking for...
-
WEB Standalone console APP “Indy http” in production ?
borni69 replied to borni69's topic in Network, Cloud and Web
Not sure I understand you but in Delphi you can. 1) File - New - other - Web - Web Server Application - -Wizzard 2 ) Then select Windows and Linux 3) Stand alone Console app 4) port 8080 5) Complete Add Linux and compile.. then it should work. Maybe I misunderstood your question.. B -
WEB Standalone console APP “Indy http” in production ?
borni69 replied to borni69's topic in Network, Cloud and Web
Thanks for this update 🙂 We will test it ... -
WEB Standalone console APP “Indy http” in production ?
borni69 replied to borni69's topic in Network, Cloud and Web
Thanks, we also use 80 threads today so this is the same 🙂. -
WEB Standalone console APP “Indy http” in production ?
borni69 posted a topic in Network, Cloud and Web
Hi today we run our backend API system on Linux Ubuntu using ISAPI mod files on Linux With apache in front. We run this system in docker containers. We have autoscale when the system reaches 80 simultane requests, it increases a new docker instance. Normal traffic 1 to 2 instances, peak 3. This means the Delphi app will never need to handle more than 80 requests at the same time. We are considering to do this with a new setup using an Nginx proxy in docker, and then use standalone console APP to handle the requests. Is this a good idea ? Is a standalone console APP “Indy http” ment for production ? or only test. Hope to get some advice Thanks -
Image pool server
borni69 replied to dkprojektai's topic in Algorithms, Data Structures and Class Design
Just an idea. you could upload all images to AWS s3, then use the event on s3 to trigger a lambda function running a delphi linux console app in docker. This example is not using Delphi, but still explain the consept using s3 as a pool. https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html We have several Delphi apps running smootly on Lambda.. We use this Lambda runtime API for our Delphi apps https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html -
In the create FMVC := TMVCEngine.Create I send in a custom logger like below GetLogger end,GetLogger); //GetLogger // Added the logger at this stage unit CustomLoggerConfigU; interface uses LoggerPro; // loggerpro core function GetLogger: ILogWriter; implementation uses System.IOUtils , LoggerPro.FileAppender ; function GetLogger: ILogWriter; begin Result := BuildLogWriter([ {$IFDEF MSWINDOWS} TLoggerProFileAppender.Create ( 10, 1000 , 'C:\hseqsetting\logs' ) {$ENDIF} {$IFDEF LINUX} TLoggerProFileAppender.Create ( 10, 1000 , '/etc/hseq/logs' ) {$ENDIF} ], nil,TLogType.Info); end; end. is this above what you mean with setcustomlogger ? This is an ISAPI app .so for Linux Apache. It was not able to create the file in the location I set in GetLogger But if I added a file manually and set chmod 0777 libmod_hseq2.00.dmvcframework.log to the file, it worked. But after the file logging worked, I was not able to use /dev/stdout My plan was to send the log to AWS cloud watch together with the apache log. So I have for now instead created a custom logger for MYSQL. I can of course be my little knowledge of the framework, and this is not an issue, but I was not able to find any examples for ISAPI Linux using log, and based on my reading I could not make it work. Do you still think I should make it an issue? Also the linux docker is Ubuntu 18.04
-
Also if someone needs it later I added the logger in the create part of TMVCEngine procedure TMyWebModule.WebModuleCreate(Sender: TObject); begin FMVC := TMVCEngine.Create(Self, procedure(Config: TMVCConfig) begin // session timeout (0 means session cookie) Config[TMVCConfigKey.SessionTimeout] := '0'; // default content-type Config[TMVCConfigKey.DefaultContentType] := TMVCConstants.DEFAULT_CONTENT_TYPE; // default content charset Config[TMVCConfigKey.DefaultContentCharset] := TMVCConstants.DEFAULT_CONTENT_CHARSET; // unhandled actions are permitted? Config[TMVCConfigKey.AllowUnhandledAction] := 'false'; // default view file extension Config[TMVCConfigKey.DefaultViewFileExtension] := 'html'; // view path Config[TMVCConfigKey.ViewPath] := 'templates'; // Enable Server Signature in response Config[TMVCConfigKey.ExposeServerSignature] := 'true'; end,GetLogger); //GetLogger // Added the logger at this stage FMVC.AddController(TMyController);
-
I will also have a look at Restappender, maybe it is a better solution for me...
-
The problem was access in my docker file I added the file libmod_hseq2.00.dmvcframework.log and chmod 0777 libmod_hseq2.00.dmvcframework.log then it works so now it seems to log fine to this file /var/log/hseq/libmod_hseq2.00.dmvcframework.log But I got a new problem I would like to send this file to "stdout" Tried using this command RUN ln -sf /dev/stdout /var/log/hseq/libmod_hseq2.00.dmvcframework.log It gives me no error but no logging is showing using docker logs <dockername> I did find something about it maybe not working because it's not in PID1? Any idea
-
Hi , I am trying to make a custom logg work in Linux , but it make the ISAPI stop running It works great in windows. I have this CustomLoggerConfigU.pas unit CustomLoggerConfigU; interface uses LoggerPro; // loggerpro core function GetLogger: ILogWriter; implementation uses System.IOUtils , LoggerPro.FileAppender // loggerpro file appender (logs to file) {$IFDEF MSWINDOWS} , LoggerPro.OutputdebugStringAppender {$ENDIF} // loggerpro outputdebugstring appender (logs to the debugger) ; function GetLogger: ILogWriter; begin Result := BuildLogWriter([ {$IFDEF MSWINDOWS} TLoggerProFileAppender.Create(10, 1000, 'C:\hseqsetting\logs') {$ENDIF} {$IFDEF LINUX} TLoggerProFileAppender.Create(10, 1000, '/etc/hseq/logs') {$ENDIF} ], nil,TLogType.info); end; end. and in my webmodule i have added MVCFramework.Logger to uses and use the following code to trigger SetDefaultLogger ........ procedure TMyWebModule.WebModuleDestroy(Sender: TObject); begin FMVC.Free; end; initialization DataModuleDict:= TDataModuleDict.Create(nil); DataModuleDict.initDict; SetDefaultLogger(GetLogger); finalization DataModuleDict.Free; end. System run ok if I remove SetDefaultLogger(GetLogger); , but if it is present i get this line in terminal, but after it hang root@5e5f9a598ac5:/etc/hseq/logs# cat libmod_hseq2.00.dmvcframework.log 2022-03-22 18:57:54:100 [TID 274930554752][INFO ] Custom Logger initialized [dmvcframework] root@5e5f9a598ac5:/etc/hseq/logs# So its initialized but then hole system hang... not able to run before i comment out line below //SetDefaultLogger(GetLogger); Is this not the correct way to do this on Linux ? thanks in advance
-
Great Thanks 🙂
-
I have this code procedure THseqScimController.createUser; var aUser : TUser; begin aUser := Context.Request.BodyAs<TUser>; try if UserScimHandleClass.CreateUser(aUser) then begin Render(aUser,false); Context.Response.StatusCode:=201; end else raise EMVCException.Create(HTTP_STATUS.Conflict,'Conflict'); finally aUser.Free; end; End; It works great from postman with this content type application/json But when request come from Microsoft Azure it have this content type application/sim+json And it gives me an error on aUser := Context.Request.BodyAs<TUser>; Body content type not supported… Is there a way to change this application/sim+json to application/json or to add application/sim+json as a supported type ? I guess other option is to parse json and build the object myself Thanks