sshkit - A toolkit for deploying code and assets to servers in a repeatable, testable, reliable way.

  •        0

The typical use-case looks something like this:```rubyrequire 'sshkit/dsl'on %w{}, in: :sequence, wait: 5 do within "/opt/sites/" do as :deploy do with rails_env: :production do rake "assets:precompile" runner "S3::Sync.notify" execute "node", "socket_server.js" end end endend```One will notice that it's quite low level, but exposes a convenient API, the`as()`/`within()`/`with()` are nestable in any order, repeatable, and stackable.When used inside a block in this way, `as()` and `within()` will guardthe block they are given with a check.In the case of `within()`, an error-raising check will be made that the directoryexists; for `as()` a simple call to `sudo su - whoami` wrapped in a check forsuccess, raising an error if unsuccessful.The directory check is implemented like this: if test ! -d ; then echo "Directory doesn't exist" 2>&1; false; fiAnd the user switching test implemented like this: if ! sudo su -c whoami > /dev/null; then echo "Can't switch user" 2>&1; false; fiAccording to the defaults, any command that exits with a status other than 0raises an error (this can be changed). The body of the message is whatever waswritten to *stdout* by the process. The `1>&2` redirects the standard outputof echo to the standard error channel, so that it's available as the body ofthe raised error.Helpers such as `runner()` and `rake()` which expand to `execute(:rails, "runner", ...)` and`execute(:rake, ...)` are convenience helpers for Ruby, and Rails based apps.



comments powered by Disqus

Related Projects