			Notes about Runfactor
			    Derek Atkins
			  <warlord@MIT.EDU>
			      1 Nov 93

$Id: README,v 1.1 1993/11/02 05:18:23 warlord Exp $

	INTRODUCTION
	------------

	This is the runfactor distribution.  Runfactor is a program
which is used in conjunction with mpqs to try to automate running
mpqs, and try to keep machine load to a minimum.  Runfactor will get a
unique UID from a list of ID's and pass it to mpqs.  It will then sit
and watch the system load, tty usage, and other places for the machine
usage, and it will stop the mpqs process as appropriate.

	Runfactor has not been widely tested, and may not work on many
platforms.  It is released only as a helpful utility, and may not
function properly.  Any patches or fixes would be helpful.  I cannot
guaratee that it will work in your environment.  I have only
successfully tested it on a DECstation.

	HOW RUNFACTOR WORKS
	-------------------

	Runfactor should be run out of cron, or at least run at system
boot time.  When runfactor is started, it will check to see if there
is another runfactor or mpqs running, and if so, it will exit.  If
there is not such a process running, it will attempt to process any
remaining relations using the program "sendit" (supplied herein).
This function can either move the relations to someplace else, or mail
them off as appropriate.

	Once all the checking is done, runfactor will attempt to
acquire a unique ID for this mpqs.  It does this by reading the
TASKLIST file, taking the first available task and then modifying the
file to reflect the remaining tasks.  It will then use the TEMPLATE
file and put the UID in its place, and then send this to mpqs.

	Now that mpqs is running, runfactor will sleep in the
background, waking up every minute to check the available information
sources to machine usage.  If the machine is sufficiently used at the
time, it will send a SIGSTOP to mpqs.  Runfactor will then wait until
the machine is no longer sufficiently used, and will then continue the
mpqs process.

	THE TASKLIST FILE
	-----------------

	The tasklist is a file that contains two numbers per line.
The first number is a starting UID, and the second number is the
number of consecutive UIDs following that number.  For example,
suppose you request 10 UIDs from the factorid server, and it responds
with numbers 1-11, then your TASKLIST file will contain the one line:

1 10

If you also get another 10, which start at number 256, then your
TASKLIST will contain:

1 10
256 10

And so on.  Note that all hosts must have access to the same TASKLIST
file, and each most must be able to modify the file!

	BUILDING RUNFACTOR
	------------------

	Since you are reading this, you must have already unpacked the
runfactor sources.  You should read the Makefile and set your site
variables.  Such variables include the locations of some files, such
as TASKLIST and TEMPLATE, locations of programs, like mpqs and uptime,
and other site definitions.

	Once you have your site definitions set up, you can attempt to
build it for your machine.  If you type "make", it will give you the
list of machines that it will (most likely) build under.  If your
machine does not exist, then you will have to attempt to create a Make
rule for your machine.  If you are successful, please send mail
indicating this fact.

	RUNNING RUNFACTOR
	-----------------

	Runfactor has a number of command-line options which control
how it behaves.  Also, runfactor needs to have "sendit" in its path.
Anyways, the command-line options are:

	-l	Pauseload.  This is the machine load at which
runfactor will stop the mpqs process.  It is a floating-point number,
so you can say something like "-l 1.75".  If this is not given, then
the load will not be checked.

	-L	Resumeload.  This is the machine load at which the
mpqs process will be restarted once its stopped.  In other words, it
is the load threshold for running the mpqs process.  If this option is
not given, and the pauseload is given, then the resumeload will be
defined as 1/2 the pauseload.  Defining resumeload without pauseload
is undefined.

	-t	Ttypause.  This is the amount of idle time needed on
all active ttys for mpqs to be allowed to run.  If this option is not
used, then tty idle time will be ignored.  If this option is used,
then whenever any used tty is non-idle, mpqs will be stopped, and it
will not be started until the ttypause threshold is met.  The
threshold is the argument, which is the number of minutes of idle time
required before mpqs will be restarted.  (If the argument is > 120,
then it is the number of seconds of idle time required).

Enjoy!

-derek
