Running the TaskForest Web Server

The TaskForest package includes two simple, low-footprint web servers, called `taskforestd` and `taskforestdssl`, written in perl. They are identical in every way, except that the latter is a secure SSL version. See the web server security page for more info. The webserver uses the LWP library and its sole purpose is to give you an web-based interface to TaskForest. I chose to write a perl-based web server because it is easy for users to download, install and deploy. Also, it may be too much to ask users to install and mantain Apache, and configure mod_perl, just to get this web-based access.

The behavior of `taskforestd` is controlled with a configuration file, `taskforestd.cfg`. This configuration file must be customized as described below, before you can use the web server. Once you have customized the configuration file, you can start web server like this:

    taskforestd --config_file=taskforestd.cfg

    OR

    taskforestdssl --config_file=taskforestd.cfg

You can stop the web server like this:

    taskforestd --config_file=taskforestd.cfg --stop

    OR

    taskforestdssl --config_file=taskforestd.cfg --stop

For example, if the configuration file specifies that the host on which `taskforestd` runs is www.example.com, then the web server will be available at http://www.example.com/ .

To use the webserver (or even the web service described later) you must have a valid userid and password. `taskforestd` does not ship with any default userid and password pairs. A password is required to authenticate the person making requests via the web browswer. This userid and password combination may be (and should be) different from the userid and password of the account under which taskforestd is running.

A Sample `taskforestd` Configuration File

    # This is a sample taskforestd configuration file

    # Please change all settings to values that make sense
    # for you.

    # These are the four required command line arguments to
    # taskforest
    log_dir         = "t/logs"
    family_dir      = "t/families"
    job_dir         = "t/jobs"

    # This is a file that ensures that only one child
    #  process can accept connections at any time
    lock_file       = "t/lock_file"

    # The HTTP server document_root
    document_root   = "htdocs"

    # The host on which the taskforest daemon will run
    host            = "127.0.0.1"

    # The port on which to listen for connections
    port            = 1111

    # The number of children available at any time
    child_count     = 10

    # The number of requests each child process should
    # serve before exiting.
    # (To protect from memory leaks, etc)
    requests_per_child = 40

    # Every time a child dies wait this much time (in
    # seconds) before starting a new child. Do NOT set
    # this value to less than 1, otherwise you may
    # encounter CPU thrashing.  Set it to something like
    # 10 seconds if you're testing.
    respawn_wait    = 1

    # my default, log stdout messages with status >= this.
    # This only effects stdout
    # The sequence of thresholds (smallest to largest is):
    # debug, info, warn, error, fatal
    log_threshold   = "info"

    # These file names should NOT end with '.0' or '.1'
    # because then they will be mistaken for job log files
    #log_file        = "taskforestd.%Y%m%d.%H%M%S.stdout"
    #err_file        = "taskforestd.%Y%m%d.%H%M%S.stderr"
    log_file        = "taskforestd.stdout"
    err_file        = "taskforestd.stderr"
    pid_file        = "taskforestd.pid"

    # Run as a daemon (detach from terminal)
    run_as_daemon   = 1

    #
    # In order for the web site to work, you must have
    # at least one valid user set up.  As the commented
    # examples below show, you may have more than one.
    # The value of each valid_user option is the login
    # followed by a colon (:) followed by a crypt hash
    # of the password.  There are many ways to generate
    # the crypt hash, including using the crypt perl
    # function.  You can also use the gen_password
    # script included with this release.
    #
    #valid_user = "test:e3MdYgHPUo.QY"
    #valid_user = "foo:jp8Xizm2S52yw"

    # The path to the server private key file
    server_key_file   = "certs/server-key.pem"

    # The path to the server certificate
    server_cert_file  = "certs/server-cert.pem"