You are not logged in.
I have developed a program using the example "Synopse OpenSource \ SQLite3 \ Samples \ 04 - HTTP Client-Server" creating a server-type Console Application. Now I would like to turn the server on a service, what should I write? I ask this because I have created a "Service appliaction" with delphi and then I added the connection to the server SQLite but it don't work
Offline
How do you make the connection?
This is very difficult to find what's wrong with your code with so few information.
mORMot is used on production with the server installed as a service, without any problem.
Take a look at the "10 - Background Http service" demo, which is just a HTTP server implemented as a Windows service, using our dedicated SQLite3Service unit, which is more lightweight than the default Delphi service implementation.
I forgot to commit this sample file some weeks ago - it is now available at http://synopse.info/fossil/finfo?name=S … ervice.dpr
Sorry!
Offline
I sorry, but your example number 10 not working, it not generated any sqlite files and even the log file
Offline
Also for me the demo 10 doesn't work. Tested on Windows XP.
Offline
I didn't look at "10 - Background Http service" example, but maybe is there some issue which is explained here.
I'm having same source code at "3" different application implementations (different compiler defines) and works just fine (at least for named pipes at mORMot level):
1. For simple testing I implemented first as all in one GUI exe.
2. Then I separated on client\server part, client as GUI exe, server as console app.
3. At last I implemented server part as windows service too.
My favorite approach is not via sub-classing, but as composition (TService is just member).
So in short you need somewhere next basic things (approach is similar to the SvcMgr.TService):
winService: TService;
(...)
procedure ServiceControlHandler(CtrlCode: DWord); stdcall;
begin
winService.DoCtrlHandle(CtrlCode);
end;
(...)
winService := TService.Create(SERVICE_NAME, SERVICE_DESC);
winService.ControlHandler := ServiceControlHandler;
winService.OnStart := StartHandler; //* In this handler you implement mORMot startup
winService.OnStop := StopHandler; //* ...here the mORMot shutdown
winService.OnResume := StartHandler;
winService.OnPause := StopHandler;
ServicesRun; //* this is blocking function, here you put control to the windows service manager
(...)
Last edited by Leander007 (2012-02-28 18:56:15)
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline
Yes I think that the latest modifications made to the SQLite3Service.pas file did break the implementation of this unit.
See http://synopse.info/fossil/finfo?name=S … ervice.pas
But in all cases, there is no problem running mORMot as a service, even if this unit is not 100% working.
I do not have time to fix it yet - so you can either use the regular Delphi service implementation (which is bigger, but more standard), or use a previous revision of the SQLite3Service.pas unit.
If you find the issue, let us post the fix here, so that we may commit a working file.
Offline
Your TService does work in all cases if control handler is explicitly assigned (not via "assembler" trick, this fails) as is already stated by my previous post:
winService.ControlHandler := ServiceControlHandler;
In my example has been used SQLite3Service.TService not SvcMgr.TService.
Last edited by Leander007 (2012-02-29 00:18:49)
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline
How is possible to patch the code to run the example?
Offline
I just checked example. HERE IS THE SOLUTION!
There are two issues, one is minor related to the automatic assigning of handler (I didn't investigate further, because "basic pascal" works always as I told already in previous posts) and the other to "not assigned global constants in class creation" (I think compiler stuff, Arnaud will know about this better ).
So, Arnaud if you can include this corrections:
1. Problem: Constants should be moved to the class (it is better looking anyway , more object approach ):
TSQLite3HttpService = class(TService)
public
const
SERVICENAME = 'mORMotHttpServerService';
SERVICEDISPLAYNAME = 'mORMot Http Server Service';
var
(...)
if param='/install' then
TServiceController.CreateNewService('','',TSQLite3HttpService.SERVICENAME,
TSQLite3HttpService.SERVICEDISPLAYNAME, paramstr(0),'','','','',
2. Problem:
then next part of code, should be included\changed. Asm magic does not properly stop service, but startup and communication was ok with it:
procedure ServiceControlHandler(CtrlCode: DWord); stdcall;
begin
Service.DoCtrlHandle(CtrlCode);
end;
{ TSQLite3HttpService }
constructor TSQLite3HttpService.Create;
begin
inherited Create(SERVICENAME,SERVICEDISPLAYNAME);
ControlHandler := ServiceControlHandler;
(...)
Last edited by Leander007 (2012-02-29 14:13:49)
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline
This was tested with current code as basis and compiled with Delphi 2009, running on Vista .
Last edited by Leander007 (2012-02-29 14:20:36)
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline
Fix committed - see http://synopse.info/fossil/info/215e44e66b
Offline
I hate to burst everyone's bubble, but the problem still persists, at least with D2007 or XE2, even with the latest download http://synopse.info/fossil/info/215e44e66b.
I have tested it on Win7 (32 bit or 64-bit) and XP SP3 in a VirtualBox as Administrator.
I can install it, but it won't start. If I try and start it manually in the Services window it I get "Error 1053: The service did not respond to the start or control request in a timely fashion.".
I checked the latest Synopse source code (downloaded today) and Leander007's changes are in there. If someone wants to give me a link to their "httpservice.exe" I can run it here to see if the problem is Windows or my installation of mORMot.
Like I said, I just downloaded "Synopse OpenSource-215e44e66b1226ae.zip" and installed it an hour ago.
Brent
Offline
Yes. I opened a DOS window as Administrator and typed:
httpservice /install
httpservice /start
The /install worked (appears in Services window), but the /start is ignored and no log file produced. I assume the log file would be produced in same directory as the .exe. The /uninstall also does NOT work. I had to execute a "SC Delete mORMotHttpServerService" to uninstall it from the Services window before I try again.
Brent
Win 7 32-bit (default OS)
Delphi XE2 32-bit (default, I have all Delphi versions installed in XP Virtual Box)
Offline
Arnaud missed the first problem with constants (is not yet corrected in source, all my changes are not there), so if you made corrections as I suggested (http://synopse.info/forum/viewtopic.php?pid=3683#p3683) then it must worked .
Esmondb obviously did follow both suggestions (I'm using this as daily practice, so it is WORKING).
I'm repeating myself to often .
Last edited by Leander007 (2012-04-10 21:25:32)
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline
Leander007,
When I took a look at the code changes in today's download, I realized Arnaud missed including the constants in the TSQLite3HttpService class, but I thought it was all aesthetics as to where the constants were declared. My Bad!
I'm repeating myself to often smile.
Yeah, I'm getting a little dense in my old age. It's working now. Thanks for the help.
Brent
Offline
Using const within class is not compatible with all versions of Delphi handled by the framework.
That is the reason why it was not included in the trunk.
In fact, the error was that there was already a property of TService named SERVICENAME (ServiceName).
I renamed those, and it worked as expected:
const
HTTPSERVICENAME = 'mORMotHttpServerService';
HTTPSERVICEDISPLAYNAME = 'mORMot Http Server Service';
In fact, the trick of ServiceControlHandler() with a global was not even necessary.
Offline
See answer .
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline