Giter Club home page Giter Club logo

clojure-control's People

Contributors

aterreno avatar dhilipsiva avatar killme2008 avatar ljos avatar sunng87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clojure-control's Issues

`ssh` execute command in path

I guess my post is more a question than a real issue, but here it is (worst case is, you get to see how a user of your lib for a few hours try to do) :
I am trying to define a task to get the git branch of a repository.

Here is what I have so far :

(deftask :git-branch []
  (ssh (run
         (cd (:path @config))
         (run "pwd") ;; this println nicely /var/dev/my-repo => ok
         (run "ls -a") ;; this lists the right content                => ok
         (run "git rev-parse --abbrev-ref HEAD") ;; master => ok

         ;; strangely this is listed before
         ;; and it fails with :
         ;; stderr  fatal: Not a git repository (or any of the parent directories): .git
         (let [rt (ssh "git rev-parse --abbrev-ref HEAD")]
           (println "status " (:status rt))
           (println "stdout " (:stdout rt))
           (println "stderr " (:stderr rt)))

         ;; I am in my home repository
         ;; how can use `ssh` to get a result
         ;; while being in a repository ?
         (let [rt (ssh "pwd")]
             (println "status " (:status rt))
             (println "stdout " (:stdout rt))
             (println "stderr " (:stderr rt))))))

I am confused by the rules of the paths. I expected all calls inside cd to have the same path. Also, how can I get the result of "git rev-parse --abbrev-ref HEAD" in the right folder ?

Unable to set env var "CONTROL-DIR" / Specify control file explicitly

I want to invoke a default control.clj to utilize some system level tasks no matter which folder I am.

Basically what I'm intended to do is just

alias ctrl="CONTROL-DIR=~/bin control"

(~/bin is where I put my default control.clj into)

Just found that hyphen(-) is not allowed within bash variable name, so seems not so easy to set CONTROL-DIR env variable. Is it better to change it into CONTROL_DIR? Or is there any other approach to fulfill my requirement? I mean, to have a "default" control.clj.

Actually I'm considering replacing some tasks originally written by Ant with clojure-control. With Ant I can specify the build file by -f filename.xml. It'll be great if I can also specify control file in clojure-control.

Thanks a lot for your great work.

Possible to access my project's namespace from a control.clj file?

Hi! I'm trying to use control to deploy some stuff to Amazon AWS.

It's basically working ok, but I'm running into some problems trying to use libraries inside of the control.clj file. Specifically, I'd like to be able to import amazonica and take some running servers out of rotation on the load balancer before I ssh to them and deploy the new code.

The problem seems to be that control runs with its own classpath and I'm not sure how to access my project's own namespaces and dependency tree from within it.

I was able to get part of the way there by using the lein plugin, and then following this suggestion to import stuff into the control.clj file:

https://groups.google.com/forum/#!topic/clojure/zaWyOHF7yxI

...but it's not working perfectly, and I wind up having to keep two copies of my dependency list around.

Do you have any suggestions about making this happen? My ideal state is that I'd have some simple deployment code in a library in my own project, and then in control.clj call something like

(require '[myproject.aws :as aws])

(deftask :remove-elb "Remove a thing from another thing" []
  (aws/remove-from-elb "server-name")
  (ssh "somewhere" "whatever")

Handle errors by stopping execution

Hello again :)

I came across a case that I think could be improved (unless I missed something and it is already present). Here was the output from my console when running clojure-control :

localhost:ssh:  cd /var/dev/my-repo/ ; git clone [email protected]:nha/my-repo.git
localhost:stderr: zsh:cd:1: no such file or directory: /var/dev/my-repo/
Cloning into 'my-repo'...
localhost:exit: 0

As you can see, the cd command failed because the directory didn't exist.
And then the clone command fired up anyway.
So the clone ended up in my home repository.

I can see two possible solutions :

  • replace the ";" delimiter with a "&&" delimiter. This is probably a quick-fix, and it relies on commands to return standard success/error codes.

  • set bash flags for the duration of the command :

    set -o errexit
    set -o pipefail
    set -o nounset

What do you think ?

Thank you for making this library.

Run a local task once?

I have a build task that is part of an overall deploy task. The idea is the build task (compilation, uberjar) should occur once per deploy, and the remainder of the tasks run once per deployment (scp, restarting, etc.)

Currently the local build task runs once per node in the cluster. How would one ensure this runs only once for a deployment?

Task <taskname> just needs -2 arguments

Hello,

With even a freshly initialized control.clj I'm unable to run any tasks. The message returned from control is always that the task "just needs -2 arguments".

lein version:
Leiningen 1.7.0 on Java 1.6.0_31 Java HotSpot(TM) Client VM

Cheers,
Chip

Unable to use timeouts on SSH

I have forked your repo, as I may need to implement SSH timeouts. As far as I understand the tool currently does not support something like "ssh -o ConnectTimeout=10". This manifests as an issue if there are many operations in the queue so many of the SSH requests won't be processed for a long period time. Do you plan to fix or have a work around for it as of now?

run example (deftask :create-dir []) : no tty present

I am trying to create a folder, using the task as specified in the guide :

(deftask :create-dir []
  (if (not (exists? (str (:path @config))))
    (ssh (sudo (str "mkdir -p " (:path @config))))))

I get an error :

sudo: no tty present and no askpass program specified

After googling for the error, I get to this SO post :

http://stackoverflow.com/questions/21659637/how-to-fix-sudo-no-tty-present-and-no-askpass-program-specified-error

And I add :ssh-options to my local cluster :

(defcluster :local
  :clients [{:host "localhost" :user "nha"}]
  :ssh-options "-t")

This time I get :

localhost:ssh: -t test -e /var/dev/clojure-cms
localhost:stderr: Pseudo-terminal will not be allocated because stdin is not a terminal.
localhost:exit: 1
localhost:ssh: -t sudo mkdir -p /var/dev/clojure-cms ;
localhost:stderr: Pseudo-terminal will not be allocated because stdin is not a terminal.
sudo: no tty present and no askpass program specified

Following the trail, I get to this post :
http://stackoverflow.com/questions/7114990/pseudo-terminal-will-not-be-allocated-because-stdin-is-not-a-terminal

I try "-t -t", and "-T", none of these work.

localhost:ssh: -t -t test -e /var/dev/clojure-cms
localhost:stderr: ssh: illegal option --  

And :

localhost:ssh: -T test -e /var/dev/clojure-cms
localhost:exit: 1
localhost:ssh: -T sudo mkdir -p /var/dev/clojure-cms ; 
localhost:stderr: sudo: no tty present and no askpass program specified
localhost:exit: 1

What should I do ?

Note : I am on osx 10.10.5, tried from a bash and zsh shell in case it matters.

starting a remote process

not sure this is an issue, but this is the only place for help on this. how would i start a blocking process remotely. i would normally use '&', but I get an error complaining about the ';'. Not sure if it is just a ssh connection that I am missing. but i would greatly appreciate any help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.