Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Simple parallel server cluster management tool for Node using ssh and scp

tag: v0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Readme.md

shync

Simple parallel server cluster management tool for node using ssh and scp. Specify an ssh or scp command and it will run on all servers in the cluster in parallel.

ssh

var Shync = require('shync').Shync;

var cluster = new Shync({
  domains: ['23.42.103.164',
            'mydomain.com'],
  user:    'ubuntu',
  keyLoc:  '/path/to/publick/key',
  bypassFingerprint: true
});

cluster.run('node ~/stuff/important.js', function(code){
  if (code === 0){
    console.log('you\'ve done something important on many machines!');
  }
});

scp

cluster.run('~/important.tar.gz', '~/stuff/important.tar.gz', function(code){
  if (code === 0){
    console.log('you\'ve done something important on many machines!');
  }
});

Chaining commands

cluster.run('~/important.tar.gz', '~/stuff/important.tar.gz', function(code){
  if (code === 0) {
    cluster.run('tar xzvf ~/stuff/important.tar.gz', function(code){
      if (code === 0){
        cluster.run('node ~/stuff/important.js', function(code){
          if (code === 0){
            console.log('you\'ve done something important on many machines!');
          }
        });
      }
    });
  }
});

code === 0

shync callbacks always receive the return code of the command that was run. If the command was unsuccessful or otherwise returned something other than 0, the first non-zero return code will be passed.

bypassFingerprint

var cluster = new Shync({
  ...
  bypassFingerprint: true
  ...
});

You know when you ssh from the command line into a brand new box, and you get this message:

$ ssh user@example.com
The authenticity of host 'example.com (23.20.102.179)' can't be established.
RSA key fingerprint is 2f:5d:69:26:e2:a0:23:53:f7:0a:21:51:0a:74:8a:49.
Are you sure you want to continue connecting (yes/no)?

bypassFingerprint: true stops this from happening.

Warning Use bypassFingerprint at your own risk.

Something went wrong with that request. Please try again.