Thursday, October 30, 2008

Athenaeum Server Scripts







Athenaeum Clients (command-line, JAS and Web Service) call Python functions on  Athenaeum Servers.

Some functions are server specific, that means that they can run only on dedicated servers as they depend on the server environment. Clients may access Server functions via multiple front-ends, using specific Client scripts. Some Clients may not support some Server functions.

Standard Athenaeum distribution supports three functions:

  • Cool allows to browse Cool DB using Athena Server. You can connect to any Cool database by filling connection parameters. Its functionality is implemented by the Client script.

  • Event gives ntuple representation of the current Athena event. Its functionality is implemented by the Client script.  (currently only available via JAS client)

  • Extract extracts a ROOT Collection with all references and all metadata from a relational TAG database for use as input to an analysis job. It is implemented by the Extract(...) function.  (currently only available via Web Service client on the ELSSI Gateway)


Other functions are general, they can be implemented on any server:

  • Help gives help from running Server, if implemented by the help() funcion.

  • Restart restarts running Server, if implemented by the restart() function. User should wait about a minute before sending new requests to the Server.

  • Fork starts new (personal) Server on chosen port, if implemented by the fork(port) function. User should wait about a minute before sending new requests to the Server.


Some functions are available on all servers, they don't need any special implementation:

  • Info gives basic information about running Server.

  • Log gives log of latest task on the selected server:port. (depends on http server, which may be unavailable or hidden behind a firewall)

  • Dummy allows to run any Python Script on the Athena Server.


Standard Server script should look like this:

#--------------------------------------------------------------
# Define all callable functions and environment
#--------------------------------------------------------------
def abc():
print "abc"

#--------------------------------------------------------------
# Define Help
#--------------------------------------------------------------
def help():
print "This is the help !"

#--------------------------------------------------------------
# Define Restarting
#--------------------------------------------------------------
def restart():
os.spawnlp(os.P_NOWAIT, "athena.py", "athena.py", "-i", "-s", "Server.py")

#--------------------------------------------------------------
# Define Forking
#--------------------------------------------------------------
def fork(port):
os.environ["ATHENAEUM_PORT"] = port;
os.spawnlp(os.P_NOWAIT, "python", "python", "Server.py")

#--------------------------------------------------------------
# Start the Server
#--------------------------------------------------------------
argumentInteractiveServerNoAlgTools = True
argumentInteractiveServerServerPort = os.environ["ATHENAEUM_PORT"]
argumentInteractiveServerServerKey = "mykey"
execfile ("InteractiveServer.py")


Server script should be in the same directory as Interactive Server scripts. They are available from the Athenaeum distribution directory src/Server/Common.

Server script can be started (usually from cron) by a simple shell script like this:

# Define server port
export ATHENAEUM_PORT="11111"
# Start Http server, if remote access to log files is required
python -u StartHttpServer.py &
# Start XML-RPC server itself
python -u StartServer.py

Some examples of the complete server setup are available from the Athenaeum distribution directory src/Server.

More information about Athenaum is available from its Home Page, Web Service and New Athenaeum command available blog entry.

No comments:

Post a Comment