莊周夢蝶

          生活、程序、未來
             :: 首頁 ::  ::  :: 聚合  :: 管理
          update: Allow passing command line arguments to task now.

          1.What is clojure-control?

              The idea came from node-control.
              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.

          2.Quick example

          Get the current date from the two machines listed in the 'mycluster'  config with a single command:

               (ns samples
               (:use [control.core :only [task cluster scp ssh begin]]))
               ;;define clusters
               (cluster :mycluster
                           :clients [
                                         { :host 
          "a.domain.com" :user "alogin"}
                                         { :host 
          "b.domain.com" :user "blogin"}
                                       ])
               ;;define tasks
               (task :date 
          "Get date"
                        []
                        (ssh 
          "date"))
              ;;start running
              (begin)

              If saved in a file named "controls.clj",run with   

          java -cp clojure.jar:clojure-contrib.jar:control-0.1-SNAPSHOT.jar clojure.main controls.clj mycluster date

              Each machine execute "date" command ,and the output form the remote machine is printed to the console.Exmaple console output

           

              Performing mycluster
              Performing date 
          for a.domain.com
              a.domain.com:ssh: date
              a.domain.com:stdout: Sun Jul 
          24 19:14:09 CST 2011
              a.domain.com:exit: 
          0
              Performing date 
          for b.domain.com
              b.domain.com:ssh: date
              b.domain.com:stdout: Sun Jul 
          24 19:14:09 CST 2011
              b.domain.com:exit: 
          0

              Each line of output is labeled with the address of the machine the command was executed on. The actual command sent and the user used to send it is displayed. stdout and stderr output of the remote process is identified as well as the final exit code of the local ssh command.


          3.How to scp files?
              Let's define a new task named deploy

            (task :deploy "scp files to remote machines"
                  []
                  (scp (
          "release1.tar.gz" "release2.tar.gz""/home/alogin/"))

              Then it will copy release1.tar.gz and release2.tar.gz to remote machine's /home/alogin directory.

          4.Where is it?

              It's on github,https://github.com/killme2008/clojure-control

              Any suggestion or bug reports welcomed.
          主站蜘蛛池模板: 宣武区| 卢湾区| 鹤岗市| 广安市| 治县。| 泰兴市| 平遥县| 宝兴县| 岱山县| 平塘县| 勃利县| 鹤庆县| 漳州市| 辰溪县| 定西市| 土默特右旗| 江华| 仙居县| 南丰县| 武胜县| 丘北县| 宝鸡市| 西和县| 昭觉县| 巧家县| 营山县| 盈江县| 麻城市| 社旗县| 林州市| 嘉义县| 遵义县| 漳平市| 嘉义市| 上犹县| 镇原县| 额济纳旗| 兴文县| 吉林省| 色达县| 苗栗市|