var co = require('co');
var wait = require('co-wait');
var request = require('co-request');
var digitalocean = require('digitalocean');
var parseArgs = require('minimist');

var argv = parseArgs(process.argv.slice(2));

var mainUrl = argv.main || process.env.MAIN_URL;
var localUrl = argv.local || process.env.LOCAL_URL;
var doToken = argv.token || process.env.DO_TOKEN;
var dropletId = argv.droplet || process.env.DROPLET_ID;
var floatingIp = argv.floatingIp || process.env.FLOATING_IP;

var client = digitalocean.client(doToken); 

co(function*() {
  while (true) {
    // ping the main service
    let res = yield request.get(mainUrl);
    if (res.statusCode === 200) {
      // all is fine, wait a second and recheck
      wait(1000);
      continue;
    }

    console.error('Failed to get 200 answer from %s got [%s]', mainUrl, res.statusCode, res.body);

    // -- something is wrong
    // ping local service to make sure we are ready to switch to this instance
    let localRes = yield request.get(localUrl);
    if (localRes.statusCode !== 200) {
      // local instance is not ready, retry from the top
      console.error('Failed to get 200 answer from %s got [%s]', localUrl, localRes.statusCode, localRes.body);
      wait(10000);
      continue;
    }

    try {
      console.log('Assigning floating ip %s to droplet %s', floatingIp, dropletId);

      let assign = yield client.floatingIps.assign(floatingIp, dropletId);
      console.log('Assign result: ', assign);
      wait(1000);
    }
    catch(err) {
      console.error('Faile to assign floating ip to %s', dropletId, err);
    }  
  }
});
@@ -480,16 +480,46 @@
 TING_IP;
+%0Avar rate = argv.rate %7C%7C 1000;
 %0A%0Avar cl
@@ -751,28 +751,28 @@
 %0A      wait(
-1000
+rate
 );%0A      con
@@ -1518,20 +1518,20 @@
    wait(
-1000
+rate
 );%0A    %7D

Add rate parameter