WebKit.Monitor | index /usr/local/share/webware/WebKit/Monitor.py

`Fault tolerance system for WebKit.
Contributed to Webware for Python by Jay Love.
This module is intended to provide additional assurance that the
AppServer continues running at all times. This module will be
responsible for starting the AppServer, and monitoring its health.
It does that by periodically sending a status check message to the
AppServer to ensure that it is responding. If it finds that the
AppServer does not respond within a specified time, it will start a
new copy of the AppServer, after killing the previous process.
Use::
$ python Monitor.py start
$ python Monitor.py stop
The default AppServer specified below will be used, or you can list
the AppServer you would like after ``start``.
You can have the whole process run as a daemon by specifying ``daemon``
after ``start`` on the command line.
To stop the processes, run ``Monitor.py stop``.`

Modules

``

os signal | socket sys | time |

Functions

``

checkServer(restart=True)
  `Send a check request to the AppServer.
  If restart is 1, then attempt to restart the server
  if we can't connect to it.
  This function could also be used to see how busy an AppServer
  is by measuring the delay in getting a response when using the
  standard port.`

createServer(setupPath=0)
  `Unix only, executed after forking for daemonization.`

dumps(...)
  `dumps(value[, version])
  Return the string that would be written to a file by dump(value, file).
  The value must be a supported type. Raise a ValueError exception if
  value has (or contains an object that has) an unsupported type.
  New in version 2.4: The version argument indicates the data format that
  dumps should use.`

main(args)
  `The main loop.
  Starts the server with `startServer(False)`,
  checks it's started up (`startupCheck`), and does a
  loop checking the server (`checkServer`).`

shutDown(signum, frame)
  `Shutdown handler.
  For when Ctrl-C has been hit, or this process is being cleanly killed.`

startServer(killcurrent=True)
  `Start the AppServer.
  If `killcurrent` is true or not provided, kill the current AppServer.`

startupCheck()
  `Make sure the AppServer starts up correctly.`

stop()
  `Stop the monitor.
  This kills the other monitor process that has been opened
  (from the PID file ``monitor.pid``).`

usage()

Data

``

addr = None
arguments = ['start', 'stop']
debug = True
defaultServer = 'ThreadedAppServer'
maxStartTime = 120
monitorInterval = 10
optionalargs = ['daemon']
quitstr = 'i\x16\x00\x00\x00{t\x06\x00\x00\x00formatt\x04\x00\x00\x00QUIT0'
running = False
serverName = 'ThreadedAppServer'
servernames = ['ThreadedAppServer']
srvpid = 0
statstr = 'i\x18\x00\x00\x00{t\x06\x00\x00\x00formatt\x06\x00\x00\x00STATUS0'