On 8/18/05, Ara.T.Howard <> wrote:
> On Fri, 19 Aug 2005, Joe Van Dyk wrote:
>=20
> > I'm writing an application that controls a group/cluster of linux
> > computers/nodes. I need to have a configuration file that lists the
> > nodes in the cluster.
> >
> > It would be neat if the configuration file was in Ruby. If I had
> > nodes named node1 and node3, the configuration file could look a
> > little like:
> >
> > node :node1 do
> > ip 192.whatever
> > title "Node 1"
> > end
> >
> > node :node2 do
> > ip 192.whatever
> > title "Node 2"
> > end
> >
> > So, is there some standard Ruby idiom for how to read a file and
> > execute the code? Just load the file and instance_eval it?
>=20
>=20
> harp:~ > cat a.rb
> config =3D <<-config
> nodes :
> 1 :
> ip : 192.whatever
> title : node 1
> 2 :
> ip : 192.whatever
> title : node 2
> config
>=20
> require 'yaml'
>=20
> config =3D YAML::load config
>=20
> config['nodes'].each do |nid, node|
> puts "node <#{ nid }> =3D> <#{ node.inspect }>"
> end
>=20
>=20
> harp:~ > ruby a.rb
> node <1> =3D> <{"title"=3D>"node 1", "ip"=3D>"192.whatever"}>
> node <2> =3D> <{"title"=3D>"node 2", "ip"=3D>"192.whatever"}>
>=20
> so all you have to do is 'YAML::load(IO::read(configfile))'.
>=20
> what kind of clustering are you working with?
>=20
> you may, or may not, find this useful:
>=20
> http://raa.ruby-lang.org/project/rq/
> http://www.linuxjournal.com/article/7922
Thanks for the pointers.
Essentially, there's a bunch of applications that need to be started
on a few machines.
Imagine you have 20 applications. You need to start those
applications on three different machines (nodes in a cluster). Some
applications will run on all machines, some applications will only run
on some machines. All the applications take many (20 or so)
environment options and command-line arguments and a user needs to be
able to change those options/arguments.
The users need to be able to select what application will get run on
what computer. They need to be able to make sure that the
applications haven't died, and if they have, to restart the
application. They need to be able to view log files for the
applications. Since these are real-time applications, the "cluster
manager application" that takes requests from the user's GUI and
distributes them to the computers in the cluster will probably need to
enforce certain restrictions on the user (i.e. can't run too many
cpu-intensive applications on one computer).
And because the applications and their env options and command-line
args change frequently, depending on what the user's objectives are,
it needs to be heavily driven by configuration files (that hopefully
are easy to change). I figure Ruby's syntax would be a good fit for
the configuration files.
The current design:
The GUI. The GUI is populated primarily from configuration files that
detail the available applications, their environment options and
command-line arguments.
The Cluster Manager. This connects the Node Managers to the GUIs.
Sends start and kill application requests from the GUIs to the Node
Managers, and sends node status updates from the nodes to the GUIs (so
the GUIs can see what's going on with each node and their
applications). Uses XML-RPC for communication (non-ruby clients will
need to access this).
The Node Manager. Starts and Kills applications on a node and sends
status updates (what applications are running, the node load average,
stuff like that) to the Cluster Manager. Uses DRb for communication
with the Cluster Manager.