Skip to content

stallman-cui/gleam

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gleam

Build Status

Gleam is a cluster for helping system operations. It works with etcd.

Every Gleam watches at least two files:

  • /gleam/node/$NAME - for one-node tasks;
  • /gleam/region/$REGION - for cluster tasks (Every Gleam instance can watch multi-regions).

Gleam will register itself as file /gleam/info/$NAME with running informations. It watches the file /gleam/node/$NAME for one-node tasks. If the file was changed, Gleam will be notified.

Gleam nodes watch the file /gleam/region/$REGION for cluster tasks. When the file is changed, all watching Gleam will be notified.

The message (the file contents) is JSON encoding data with the function name and data. Gleam calls the function with data.

{
    Name: (string),
    Data: (interface{}),
}

Dependencies

Installing & Running

All useful scripts were put at the directory shell.

Server node

Compile Gleam, and run it:

$ go get github.com/mikespook/gleam/cmd/gleam
$ $GOBIN/gleam

Witch takes the following flags:

  • -ca-file="": Path to the CA file
  • -cert-file="": Path to the cert file
  • -config="": Path to configuration file
  • -etcd="http://127.0.0.1:4001": A comma-delimited list of etcd
  • -key-file="": Path to the key file
  • -log="": log to write (empty for STDOUT)
  • -log-level="all": log level ('error', 'warning', 'message', 'debug', 'all' and 'none' are combined with '|')
  • -name="$HOST-$PID": Name of this node, $HOST-$PID will be used as default.
  • -pid="": PID file
  • -region="default": A comma-delimited list of regions to watch
  • -script="": Directory of lua scripts

The configuration settings will cover flags.

Client

Gleam supplies a package

$ go get github.com/mikespook/gleam

And a cli command

$ go get github.com/mikespook/gleam/cmd/gleam-client
$ $GOBIN/gleam-client

To operate Gleam nodes.

You can read client's source code for the package's usage.

The cli command takes the following flags:

  • -ca-file="": Path to the CA file
  • -cert-file="": Path to the cert file
  • -etcd="http://127.0.0.1:4001": A comma-delimited list of etcd
  • -key-file="": Path to the key file
  • -log="": log to write (empty for STDOUT)
  • -log-level="all": log level ('error', 'warning', 'message', 'debug', 'all' and 'none' are combined with '|')

And commands include :

  • call: Call a function on nodes file
  • region: List all regions
  • node: List all nodes
  • info: List all nodes info

See shell/test_*.sh for more information.

Case study

Let's see a case for synchronizing configurations.

Assume we have a cluster witch need to synchronize thire crontab configurations. In an old school way, we may use rsync, scp or something else to synchronize the configuration from one server to the others. Through gleam we just need some steps to complate this job:

  1. etcd instances are running on systems in a same cluster;
  2. gleam nodes connected to the etcd cluster should be watching a same region(Eg. default);
  3. The configuration content has been writen to a file in etcd.
  4. Tell gleam call the lua script config::sync for synchronizing configuration.
  5. Done.

See test_config_sync.sh for more details.

Authors

Open Source - MIT Software License

See LICENSE.

About

A operation cluster based on etcd

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 72.2%
  • Shell 25.1%
  • Lua 2.7%