Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: Transmitting Events Up: Internals Previous: Encoding Event Values

Subsections



Creating and Controlling Remote Clients

Clients on a remote host are controlled by a daemon called glishd. This process takes care of starting clients, checking on them as they run, and terminating them. It is Glish's intermediary on the remote machine. An important point, though, is that while glishd will create clients, all event communication between those clients and the interpreter is still done directly, via a socket connection, and not using glishd as an intermediary.

glishd is designed to be run either by root or by individual users. glishd is only started by the interpreter (on behalf of a user) if a glishd has not already been started by root on the remote machine. The behavior of glishd is different depending upon whether it is running as root or not.


glishd Started by Root

When glishd is started by root, it handles all client requests for all users on a given machine. It does this by listening to a published port (TCP port 2833) to which interpreters connect. When an interpreter connects to this port, glishd forks a copy of itself. This forked copy of glishd immediately sets its userid to the user which connected. From that point on, the forked process handles all requests from that user. In general when all of that user's interpreters exit, the forked process exits too. The only time when this isn't true is if the forked glishd started shared clients which are persistent; in this case, it sticks around to manage these remaining clients which will be used again.

glishd must be started by root for the shared client capabilities (see § 7.9) to work properly.

To identify users, glishd uses key files. Each host is assigned a unique key when glishd is set up. A key file is created for each user by Glish (if one doesn't already exist) the first time the user starts a client. It is assumed that the key directory is either network accessible, e.g. via NFS, or that the keys are distributed to all machines on which clients will be started. Note that if keys must be distributed manually, keys need to be created for users as well as hosts because the keys automatically created by Glish won't be seen on other hosts. Key files must be owned by the user to whom the key belongs and only that user should have read/write permission. Here's an example of what the keys directory for Glish might look like:

    bash$ ls -lR keys
    total 8
    drwxr-xr-x   2 jdoe          512 Sep  3 10:16 hosts/
    drwxrwxrwx   2 jdoe          512 Sep  3 10:18 users/

    keys/hosts:
    total 16
    lrwxrwxrwx   1 jdoe           17 Sep  3 10:21 milisant -> milisant.nrao.edu
    -rw-r--r--   1 jdoe          132 Sep  3 10:21 milisant.nrao.edu

    keys/users:
    total 8
    -rw-------   1 jdoe          132 Sep 14 11:48 jdoe
This is the directory hierarcy Glish expects to find for its keys. The important thing to note is that the ``hosts'' directory must be readable by all Glish users, and the ``users'' directory must be writable by all Glish users.

Key files are created by running glishkey which should be built along with Glish. Here's an example:

    bash$ glishkey 
    5971b940c8eb94edc374aa0389c46a409fbcf1c91eb3b27e0bae444ee0259f57 \
    619c5f151f059ba7186c24c8031b05a8f5f94187439cff947a0a5b1499db3ea7
    bash$ glishkey 
    5966343f14f643ae3371e7b7fbfd183253c1834e7c386e15ee164aca8eb8b11a \
    d2977ec140fbe3cd17a68c6be9f4e0a70f61b34d2040b68e82c940d77e84fcc7
    bash$ glishkey > milisant.nrao.edu
Each time glishkey is run it generates another key. A key file is created by simply piping the output of glishkey to a file.

The full path to the directory containing the ``users'' and ``hosts'' directory is built into Glish, but it can be changed from within Glish by setting system.path.key value to a specific path. The path which glishd uses can't currently be changed, though.

If you need to kill a root glishd, you should use the HANGUP signal, i.e. kill -HUP.

glishd Started by the Interpreter

If the Glish interpreter fails to connect to the glishd port, it assumes that there is no root glishd running and starts a glishd. The interpreter starts glishd using the rsh command (called remsh on some systems). Thus the user that invoked the interpreter must have an account on the remote host, and must have transparent access to that account enabled via the user's .rhosts file. Furthermore, glishd runs with that user's permissions. This glishd which was started by an interpreter does all of the things that the root glishd will do, but it only handles request from that specific interpreter. So each interpreter running remote clients on a given machine would have a glishd running. When the interpreter exits, glishd exits.

glishd Events

In addition to creating and controlling clients, glishd provides a mechanism for detecting network outages. Every five seconds the Glish interpreter sends a ``probe'' event to glishd. If it receives no response within the next five seconds, the interpreter deems network connectivity lost, generates a warning message to this effect, and creates a ``connection_lost'' event for the system agent (§ 10.11, page [*]). If glishd subsequently responds to another probe then the interpreter deems connectivity regained, reports this fact, and generates a ``connection_restored'' event for system. If glishd exits for any reason (e.g. it crashes or is killed), then the interpreter generates a ``daemon_terminated'' event for system.

glishd is itself a Glish client and responds to the following events:

setwd
specifies the working directory glishd should use when executing programs on the interpreter's behalf.

setbinpath
specifies the path glishd should search for starting clients.

setldpath
specifies the dynamic loader library path glishd should use when starting clients.

client
creates a new client. The event has a single string value, the first part of which gives an internal identifier for later use in manipulating the client, the remainder a full argument list (i.e., including executable name) for invoking the client. glishd searches for the executable using whatever $PATH environment variable it inherited via being invoked by rsh. If it cannot invoke the client it presently just generates an error message to stderr and continues. It probably should generate an event instead.

client-up
checks to see if a particular client or Glish script is already up and running, i.e. shared.

kill
terminates a client by sending it a SIGTERM signal. The string value of the kill event identifies the client to kill.

ping
pings a client by sending it a SIGIO signal. The string value of the ping event identifies the client to kill. ping supports the ping= argument of the client function. (See § 7.8.1, page [*].)

shell
executes a synchronous shell command and returns the resulting output. The value of the shell event is a record containing at least a command field giving the command to execute, and possibly a input field giving the input to be used (see the input= argument of the shell function, § 10.9, page [*]).

If glishd is unable to run the shell command it generates a fail event with a value of F. If successful then it first generates an okay event with a value of T, then a shell_out event for each line of output generated by the shell command (it would be better to buffer all of the output lines together into a single event), and finally a status event containing the exit status of the shell command. All of these events are handled directly by the Glish interpreter; they are not ``visible" in a Glish script.

probe
requests that glishd acknowledge that it is still receiving messages from the interpreter (i.e., that network connectivity holds). Ordinarily glishd immediately responds with a probe-reply event.

*terminate-daemon*
tells glishd to exit. This cannot be used to force a root glishd to exit. If you need to kill a root glishd, you should use the HANGUP signal, i.e. kill -HUP.


next up previous contents index
Next: Transmitting Events Up: Internals Previous: Encoding Event Values   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15