Main program for Netplex servers
let (opt_list, cmdline_cfg) = args():
opt_list for inclusion in the
Arg.parse option list.
The effects made available by the returned
The defaults (unless overridden by
defaults): The config file
is derived from the name of the executable (by appending
instead of the current extension). There is no config tree.
Creates the command-line configuration object.
config_tree a special configuration can be injected -
config_filename is not loaded in this case (but may
still appear in error messages)
Returns the filename of the configuration file, or the default if it has not been set on the command-line
Returns the filename of the configuration file, or
None if it
has not been set on the command-line
Establishes a configuration and starts the Netplex daemon.
If a ready-made configuration tree is included in the passed configuration
it is taken as the configuration. If otherwise only the name of the
config file is available, this file is parsed.
Netplex_config.Config_error when an error in the
configuration is detected.
late_initializer is called after the Netplex controller has been
fully initialized, and before the main event loop is entered. You can
perform here further initializations, e.g. starting helper threads.
config_parser is by default
You can override it by whatever parser you would like to use. The
parser is only used if a configuration tree is unavailable, and
the configuration needs to be loaded from a file.
As side-effect, the current logger of the [root:Netlog] module is set
to selected Netplex logger. Note that this setting remains active
startup returns to the caller. Also note that log messages
submitted via [root:Netlog] appear as from component "netplex.other"
if they are sent from outside of a container.
It is changed to
/ as working directory (as required for a daemon).
startup, but this function is tailored for Netplex
systems that compute results (e.g. Netmulticore jobs). In this
scenario, it is
not sufficient to just fire off child processes, but you also want
to return a result to the caller once the processes have finished
their tasks. One consequence of this is that you cannot daemonize
the program - it always runs in the foreground (no matter whether
-fg is given or not).
run expects that the caller passes a function
This function is invoked once the Netplex system is done, and
the user can extract the final result from the controller. The
extract_result is also the result of
At the moment
extract_result is invoked, the child processes are
already terminated. They should have put their result at a place
that is in the controller, or can be reached with the help of the
controller. The controller functionality is still fully available.
Note that the controller is shut down as soon as
returns. Further interactions with the controller are not possible.
late_initializer is now obligatory for typing reasons
(so you can get the result of the
extract_result). If you don't need it, just return
The working directory is left unchanged.
The typical main program for a
Netplex server system looks like:
let my_factories = ... let start() = let opts, cmdconf = Netplex_main.args() in Arg.parse opts (fun s -> raise(Arg.Bad ("Unknown arg: " ^ s))) "usage: protoserver"; let par = Netplex_mp.mp() in (* or Netplex_mt.mt() *) Netplex_main.startup par Netplex_log.logger_factories Netplex_workload.workload_manager_factories my_factories cmdconf Sys.set_signal Sys.sigpipe Sys.Signal_ignore; start()
This main program enables:
my_factoriesare made available for connection processing