6.8. pid

[<<<] [>>>]

pid (
    file "\\MyProjects\\sb\\httpdlog\\pid.txt"
    delay 10
    wait ( 
      period 10
      length 1

This key should have sub-keys. The key pid.file should define the pid file that the program writes. When the program starts it creates this file and writes the pid of the process into this file.

This file can be used to stop the engine. There are two ways to stop the engine. One is to use the pid and terminate the process using the command kill on UNIX or the task manager under Windows NT. This is the brute force solution and may result in data loss or data inconsistency if BASIC programs are still running.

The graceful way is to delete the created pid file.

If the pid file was created the engine checks the existence of the file every delay seconds (10 seconds in the example above). The code tries to open the file for reading. If the file exists the engine closes it and sleeps for another delay seconds.

If the file was deleted or its security attributes were set so that the engine can not read it the engine sets its internal state from running to stopping. This will inform the main thread to neglect all incoming connections, wait for the already running threads to stop and then to terminate the process.

The main thread waits period times sleeping length seconds between the periods for the threads to stop. If all threads stop the main thread does not wait longer but terminates the process. If some the thread is still executing the main thread kills those still running threads exiting the process.

It is also a graceful termination of the web server on Windows NT to use the Service Control Manager to stop the service in case the server was installed and started as a service.

[<<<] [>>>]