[AWS] AWS as a service on a Win2000 server

anders.wirzenius@wartsila.com anders.wirzenius@wartsila.com
Tue, 20 Jan 2004 08:45:25 +0200


> -----Original Message-----
> From: David Marceau [mailto:davidmarceau@sympatico.ca] wrote:
> The weird thing about nt services is that if you create a dll=20
> with too much housekeeping at the load time, the dll will not=20
> return immediately and as a result your dll will give the=20
> appearance that it failed to load and you end up with an hour=20
> glass Icon.
>=20
> nt service success trick #1
> ----------------------------
> Don't do any initialization at load time.  Have some timer=20
> actually initialize your application after 5 seconds.  That=20
> will give windows the chance to behave properly and return=20
> success for DLL_INIT...  In fact the ideal is that you just=20
> return success in the DLL_INIT part right away. There should=20
> be about three lines.=20
> 1)load dll but don't do any init.=20
> 2)set a timer with a callback that in 5 seconds it will init=20
> and start aws=20
> 3)return success.
>=20

I haven=B4t created any dll files, I just have an .exe file.
I tried to put a delay 60.0 at the beginning of the main procedure =
(runme) and then continue with declaring=20
WS   : AWS.Server.HTTP:

procedure Runme is

   use Ada;
begin
   --
   --  Delay program so that Windows is able to start the program as a =
service.
   --
   delay 60.0;

   declare
      WS   : AWS.Server.HTTP;
   begin
   --
   --  Text_IO.Put_Line ("AWS " & AWS.Version);
   --  Open databases
   HD.Database_OCI.SD.Open_SD_read;
...
but that caused the service start attempt to only struggle a few seconds =
more and then issue the error message.

Do you mean I have to put the runme in a separate package and write a =
main program?=20
Like:
with separate_package;
procedure main is
begin
   delay 5.0
   separate_package.runme;
end main;



> NT service success trick #2
> ----------------------------
> > I have tried both with
> > AWS.Server.Wait (AWS.Server.Q_Key_Pressed);
> Don't use the Q_Key_Pressed.
>=20
> AWS.Server.Wait (AWS.Server.Forever);
> This is the right approach.
>=20

Thanx. Done.

>=20
> NT service success trick #3
> ---------------------------
> In linux, to ensure the runme continues to run even after you=20
> logout, you have to do the following at the bash shell: nohup=20
> runme & The "nohup" means don't hangup this process even if I=20
> logout, and yes usually you want to run a daemon/ntservice in=20
> the background process.  At the nt command shell you can run=20
> "start /b runme" to launch it as background.  As to the nt=20
> "nohup" equivalent, it stops the service as soon as you=20
> logout if I remember correctly.
>=20
> This brings me to=20
> -INSTSRV
> -SRVANY=20
> These may already exist on your machine but maybe they are=20
> found in the NT Resource Kit. If you follow the suggestions=20
> int trick #1 and #2 above, you should be successful in a day or two.

I used instsrv to register the runme.exe as a service.
In a day or two ... hmm ... :)

>=20
> There are couple of articles about how to run a vb/c/C++=20
> application as an nt service on www.msdn.com. msdn search for=20
> the keywords "ntservice vb C++ application" and you will find=20
> what you need.
>=20

Thanks for the tip. I=B4ll try to find time for those articles.

Anders