Stem
view release on metacpan or search on metacpan
Stem Demonstration Scripts
Stem comes with several demonstration scripts and example configuration
files which are used by them. You can optionally install the executable
demonstrations and their configuration files. Note that the actual
demonstration scripts don't do anything special to Stem, they just
create windows and execute run_stem inside them with selected
configuration files. They also create telnet connections inside other
windows which you can use to interact with Stem. You can manually create
the windows and do the same commands, these scripts are just
conveniences. In fact, a good way to learn more about Stem is to copy
and modify the configuration files used in the demonstrations and run
them yourself.
When you run any of the demo scripts, the commands used to fork off an
xterm are printed. You can manually run those commands in your own
terminal windows if you want to experiment with or explore the Stem
configurations. If you kill the script (e.g. with ^C), all the created
xterm windows will be killed off leaving you with a cleaned up desktop.
There are 4 demonstration scripts that come with Stem. They are briefly
described here and in more detail in other files. They all have some
common features which are also described in detail below.
chat_demo and chat2_demo demonstrate a simple 4 user chat
server. chat_demo runs with a single Stem Hub and chat2_demo
uses 2 Hubs. Both bring up an xterm for each Stem Hub and 4 more
for the telnet sessions. Read DEMO_CHAT for the full details on
how to use this demo.
inetd_demo emulates the inetd Unix super-daemon. It runs a
single Stem Hub in an xterm and 4 telnet sessions each in their
own xterm. The server process it runs is proc_serv in the bin
directory. You can run it directly from the command to see how
it behaves (it is a simple command/response program). Read
DEMO_INETD for the full details on how to use this demo.
tail_demo monitors a typical log file and copies any new data it
finds there to a Stem Logical Log which writes it to a file and
optionally to other destinations. The status of the source file
is also sent to a Logical Log. Read DEMO_TAIL for the full
details on how to use this demo.
Using the console Cell Stem::TtyMsg
All of the demo configurations include the Stem::TtyMsg module which
allows you to enter command messages from the keyboard to a running Stem
Hub (process). This module is not required to run Stem but it is in the
demo configurations so you can interact with Stem and learn more about
it.
It reads lines from STDIN (using the Stem::AsyncIO module so the rest of
the Stem Hub continues to run), parses them and sends out a command
messages based on the lines. It also can set key/values in the local
Hub's environment (%Stem::Vars::Env) which is used to control many Stem
operations.
Command messages can generate response messages which will be sent back
to the TtyMsg Cell. These responses will be printed to STDOUT (again,
using the Stem::AsyncIO module). Any Cell can just send a data message
to the TtyMsg Cell (which is also registered with the class Cell name
tty) and its data will get printed.
The rules for parsing lines input to TtyMsg are very simple. There are
three kinds of command lines:
Direct commands
The only direct command is 'help' which has to be the
only token on the line. It causes the help text to be
printed.
Setting a Stem environment variable
Key/values in the local Hub's environment can be set
with lines of the form:
name=value
( run in 1.007 second using v1.01-cache-2.11-cpan-39bf76dae61 )