• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Clojure
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fabric in clojure

Introduction

Define clusters and tasks for system administration or code deployment, then execute them on one or many remote machines.

Clojure-control depends only on OpenSSH and clojure on the local control machine.Remote machines simply need a standard sshd daemon.

The idea came from node-control.

##News

Installation

Clojure-Control bootstraps itself using the control shell script; there is no separate install script. It installs its dependencies upon the first run on unix, so the first run will take longer.

  • Download the script.
  • Place it on your $PATH. (I like to use ~/bin)
  • Set it to be executable. (chmod 755 ~/bin/control)

The link above will get you the stable release.

On Windows most users can get the batch file. If you have wget.exe or curl.exe already installed and in PATH, you can just run control self-install, otherwise get the standalone jar from the downloads page. If you have Cygwin you should be able to use the shell script above rather than the batch file.

Basic Usage

The tutorial has a detailed walk-through of the steps involved in creating a control project, but here are the commonly-used tasks:

 control init                     #create a sample control file in current folder
 control run CLUSTER TASK <args>  #run user-defined clojure-control tasks against certain cluster 
 control show CLUSTER             #show certain cluster info.

Use control help to see a complete list.

Getting started

Creating a control file by:

control init

It will create a file named control.clj under current folder.Defines your clusters and tasks in this file,for example:

     (defcluster :default-cluster
         :clients [
                  {:host "localhost" :user "root"}
         ])
     (deftask :date "echo date on cluster"  []
         (ssh "date"))

It defines a cluster named default-cluster,and defines a task named date to execute date command on remote machines.Run date task on default-cluster by:

control run default-cluster date

Output:

    Performing default-cluster
    Performing date for localhost
    localhost:ssh:  date
    localhost:stdout: Sun Jul 24 19:14:09 CST 2011
    localhost:exit: 0

Also,you can run the task with user@host instead of a pre-defined cluster:

	 control run root@localhost date

You may have to type password when running this task. You can setup ssh public keys to avoid typing a password when logining remote machines.please visit HOWTO: set up ssh keys

Every task's running result is a map contains output and status,you can get them by:

     (let [rt (ssh "date")]
       (println (:status rt))
       (println (:stdout rt))
       (println (:stderr rt)))

You can do whatever you want with these values,for example,checking status is right or writing standard output to a file.

##Some practical tasks

A task to ping mysql:

	(deftask :ping-mysql  []
	  (let [stdout (:stdout (ssh "mysqladmin -u root  -p'password' ping"))]
	      (if (.contains stdout "is alive")
      	  1
		  0)))

A task to deploy application:

    (deftask :deploy-app []
          (local "tar zcvf app.tar.gz app/")
          (scp "app.tar.gz" "/home/user/")
          (ssh
               (run 
                   (cd "/home/user"
    				   (run
	    			      (run "tar zxvf app.tar.gz")
       	    			  (env "JAVA_OPTS" "-XMaxPermSize=128m"
                             (run "bin/app.sh restart")))))))

Two tasks to install zookeeper c client:

     (deftask ldconfig
	   []
	     (ssh "ldconfig" :sudo true))

	 (deftask install_zk_client
	  []
	      (ssh
		   (run
		       (run "mkdir -p /home/deploy/dennis")
			   (cd "/home/deploy/dennis"
			           (run "wget http://labs.renren.com/apache-mirror//zookeeper/zookeeper-3.4.3/zookeeper-3.4.3.tar.gz"))))
	     (ssh (cd "/home/deploy/dennis"
	            (run "tar zxvf zookeeper-3.4.3.tar.gz")))
         (ssh (cd "/home/deploy/dennis/zookeeper-3.4.3/src/c"
		        (run
		              (run "./configure --includedir=/usr/include")
		              (run "make")
		              (run "sudo make install"))))
		  (call :ldconfig))

##Documents

Contributors

sunng87

onycloud

ljos

dhilipsiva

##License

MIT licensed

More Repositories

1

aviatorscript

A high performance scripting language hosted on the JVM.
Java
3,954
star
2

Metamorphosis

A high available,high performance distributed messaging system.
Java
1,334
star
3

xmemcached

High performance, easy to use multithreaded memcached client in java.
Java
743
star
4

defun

A macro to define clojure functions with parameter pattern matching just like erlang or elixir.
Clojure
462
star
5

node-zk-browser

A zookeeper web administrator in node.js
JavaScript
336
star
6

gecko

A RPC framework in taobao based on java NIO.
Java
156
star
7

ip-service

A demo project for QCon meetup
Clojure
57
star
8

hs4j

HandlerSocket client for java
Java
55
star
9

storm-monitor

A monitor for storm
Clojure
46
star
10

clj.qiniu

Clojure SDK for qiniu. Clojure 七牛云存储 SDK。
Clojure
38
star
11

clj.qrgen

QRCode generator for clojure.
Clojure
34
star
12

erlwsh

Erlang web shell--program erlang on web
Erlang
32
star
13

node-shorten

A url shorten web site in node.js
CSS
28
star
14

clj-xmemcached

Memcached client for clojure.
Clojure
25
star
15

stm-profiler

A profiler for clojure STM
Java
23
star
16

clj-rate-limiter

Rate limiter for clojure that supports a rolling window, either in-memory or backed by redis
Clojure
22
star
17

UniqTask

A task manager for android,just like ES task manager
Java
22
star
18

ring.velocity

Render apache velocity template for ring in clojure.
Clojure
21
star
19

cscheme

Scheme interpreter in clojure
Clojure
16
star
20

cloudcode-test

Cloud code test for avoscloud
JavaScript
15
star
21

carmine-sentinel

A Clojure library designed to connect redis by sentinel, make carmine to support sentinel.
Clojure
14
star
22

clj.monitor

Monitoring applications in clojure based on clojure-control.
Clojure
14
star
23

ik-analyzer

An ik-analyzer github fork,ik-analyzer is a chinese tokenizer used in lucene/solr.
11
star
24

jevent

libevent for java
Java
10
star
25

alfred-workflow

my workflow for alfred
10
star
26

ewok

A high available BTM transaction logs journal using bookkeeper.
Java
9
star
27

clojure-notes

clojure 源码解读
Java
9
star
28

metamorphosis-example

metamorphosis examples
Java
8
star
29

secure-rand

A Clojure library designed to generate secure random float,int,bytes and strings based on java.security.SecureRandom
Clojure
7
star
30

lighthouse

leader election and node register/discover/balance in a service cluster by zookeeper in clojure
Clojure
7
star
31

gen-node-module

the script to generate a node.js module skeleton
JavaScript
6
star
32

UniqRecorder

Android手机的万能记录器,习作
Java
6
star
33

clj.where

A clojure library to query maps in sequence.
Clojure
4
star
34

killme2008.github.com

my github page
JavaScript
4
star
35

prowl

A clojure macro and ruby script to profile clojure program.
Ruby
4
star
36

storm-metamorphosis-spout

A storm spout for metamorphosis
Java
4
star
37

ring-session-memcached

Ring sessions stored in memcached
Clojure
3
star
38

EL-benchmark

EL benchmark for aviator
Java
3
star
39

whetherweather

Weather report and alert for android
Java
3
star
40

fnil.net

My personal web site.
HTML
2
star
41

clojure-overview

首次cn-clojure聚会上介绍的《clojure概览》附带源码
Clojure
2
star
42

coding-practice

Some personal coding pratice
C
2
star
43

erlib

Erlang example code
Erlang
1
star
44

storerl

a simple key-value disk store for erlang
Erlang
1
star
45

ring-jetty-hystrix-adapter

Setup a Hystrix (https://github.com/Netflix/Hystrix) event stream with jetty for clojure.
Clojure
1
star
46

pci4clojure

Programming collective intelligence with clojure
Clojure
1
star
47

learn-node-js

my node.js example code
JavaScript
1
star
48

blog.fnil.net

My Blog Posts
JavaScript
1
star
49

corfu

Paxos in elixir, test project
Elixir
1
star
50

node-properties

A node.js module to read properties config file.
JavaScript
1
star
51

Docker-NodeJS-Ubuntu

Build a docker image that runs node.js application in ubuntu.
Shell
1
star
52

Elixir-OTP-In-Action

《OTP in action》 source code rewrite into elixir.
Elixir
1
star
53

LeanCloud-REST-API-Demo

各种语言调用 LeanCloud REST API 源码示例。
1
star
54

programming-elixir-exercises

My《Programming Elixir》 exercises
Elixir
1
star