[fpc-pascal] fpweb fcgi: auto shutdown feature

Michael Van Canneyt michael at freepascal.org
Sun May 30 14:06:20 CEST 2010



On Sun, 30 May 2010, Bee Jay wrote:

> On 28 Mei 2010, at 23:18, Michael Van Canneyt wrote:
>
>> I'll have a look at it next week. But it will be under control of an option, and this option will be 'off' by default.
>
> Another thought about this feature. I think it'd be nice if there's an option to shutdown the app gracefully. What I mean by gracefully is when the app get a shutdown request, and the option is 'on', then the app doesn't suddently terminate itself but it waits until all currently active sessions got closed and also doesn't accept new sessions. This condition (waiting for termination) status can be read by the app through a read-only flag so the app can raise an alert to end users announcing that the app is about to close so the users are asked to immediately finish their job and quit (logout). So, the app doesn't need to wait forever.
>
> What do you think, Michael?

You'll have to program that yourself, because I think it is a security leak.

But if you want it, it's really easy to do in fcl-web. 
Create a webmodule, implement the OnRequest handler of the module, and add
   Application.Terminate:=True;
   Handled:=True;
in the handler. Then register the module with the name 'shutdown'.

then
  http://www.yourhost.com/shutdown
will nicely shut down your app after handling the request properly.

Obviously, I'd add some security mechanism, like

   If ARequest.Query['password']<>'mysecret' then
     Raise Exception.Create('Wrong password. Please go away.');

if the wrong password is given ,then the exception will be translated 
to a webpage and sent back to the client.
But the url
  http://www.yourhost.com/shutdown?password=mysecret
will still shutdown your app.

Michael.



More information about the fpc-pascal mailing list