4D v14

On Server Shutdown Database Method

Home

 
4D v14
On Server Shutdown Database Method

On Server Shutdown Database Method 


 

On Server Shutdown Database Method 
Does not require any parameters

  

The On Server Shutdown Database Method is called once on the server machine when the current database is closed on 4D Server. The On Server Shutdown Database Method is NOT invoked by any 4D environment other than 4D Server.

To close the current database on the server, you can select the Close Database... menu command on the server. You can also choose the Quit command or call the QUIT 4D command within a stored procedure executed on the server.

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 remote 4D stops connecting to the server, use the On Exit database method.

 
PROPERTIES 

Product: 4D
Theme: 4D Server Database Methods

 
HISTORY 

 
SEE ALSO 

On Server Startup Database Method

 
ARTICLE USAGE

4D Server Reference ( 4D v13)
4D Server Reference ( 4D Server v12)
4D Server Reference ( 4D Server v11 SQL Release 6)
4D Server Reference ( 4D v14 R2)
4D Server Reference ( 4D v14)
4D Server Reference ( 4D v14 R3)
4D Server Reference ( 4D Server v14 R4)