On Server Shutdown Database Method

4D - Documentation   Français   English   German   4D Server 2004, Theme List   4D Server 2004, Index   Back   Previous   Next

version 6.8 (Modified)


The On Server Shutdown Database Method is called once on the server machine when you shut down 4D Server and thereby quit the database. The On Server Shutdown Database Method is NOT invoked by any 4D environment other than 4D Server.

A server database is exited if the user selects the menu command Quit on the server or if a call to the QUIT 4D command is issued by a stored procedure.

When the exit from the database is initiated, 4D performs the following actions:

If there is no On Server Shutdown Database Method, 4D Server aborts each running process one by one, without distinction.

If there is an On Server Shutdown Database Method, 4D Server starts executing this method within a newly created local process. You can therefore use this database method to inform other processes, via interprocess communication, that they must stop executing. Note that 4D Server will eventually quit—the On Server Shutdown Database Method can perform all the cleanup or closing operations you want, but it cannot refuse the quit, and will at some point end.

The On Server Shutdown Database Method is the perfect place to:

Stop store procedures automatically started when the database was opened.

Save (locally, on disk) Preferences or Settings to be reused at the beginning of the next session in the On Server Startup Database Method.

Perform any other actions that you want to be done automatically each time a database is exited.

Warning: If you use the On Server Shutdown Database Method to close stored procedures, keep in mind that the server quits once the On Server Shutdown Database Method (and not the stored procedures) is executed. If some stored procedures are still running at this point, they will be killed.

Consequently, if you want to make sure that the stored procedures are fully executed before being killed by the server, the On Server Shutdown Database Method should indicate to the stored procedures that they must end their execution (for example, using an interprocess variable) and should allow them to close (through a x seconds loop or another interprocess variable).

If you want code to be executed automatically on a client machine when a 4D Client stops connecting to the server, use the On Exit Database Method.

See Also

Database Methods, Methods, On Server Startup Database Method.


4D - Documentation   Français   English   German   4D Server 2004, Theme List   4D Server 2004, Index   Back   Previous   Next