Example #1
0
File: dustman.js Project: awlka/azk
 before(function() {
   this.timeout(0);
   var progress = (event) => console.log(`  ${event}`);
   var funcs = [
     Helpers.remove_containers,
     Helpers.remove_images,
     () => console.log("\n")
   ]
   return funcs.reduce(Q.when, Q()).progress(progress);
 });
Example #2
0
    return async(this, function* (notify) {
      var host;
      if (config('agent:requires_vm')) {
        host = config('agent:vm:ip');
      } else {
        host = port_data.gateway;
      }

      // Wait for available
      var wait_opts = {
        timeout: timeout,
        context: `${system.name}_connect`,
        retry_if: () => {
          return container.inspect().then((data) => {
            return data.State.Running;
          });
        },
      };

      notify(_.merge(port_data, {
        name: system.portName(port_data.name),
        type: "wait_port", system: system.name
      }));

      var address = `tcp://${host}:${port_data.port}`;
      var running = yield net.waitService(address, retry, wait_opts);

      if (!running) {
        var data = yield container.inspect();
        var exitCode = data.State.ExitCode;

        if (exitCode === 0) {
          throw new SystemRunError(
            system.name,
            container,
            data.Config.Cmd.join(' '),
            exitCode,
            Q(t('errors.run_timeout_error', {
              system: system.name,
              port: port_data && port_data.port,
              retry: retry,
              timeout: timeout,
              hostname: system.url.underline,
            }))
          );
        } else {
          yield this.throwRunError(system, container, null, true);
        }
      }

      return true;
    });
Example #3
0
File: api.js Project: lucasfais/azk
  },

  start() {
    return async(this, function* () {
      // Mount entries points
      this.mount();

      // Listen in unix domain socket
      var socket = config('paths:api_socket');
      yield this._clearSocket(socket);
      yield this._listen(socket);
    });
  },

  stop() {
    return (this.server) ? Q.ninvoke(this.server, "close") : Q();
  },

  // Remove socket if exist
  _clearSocket(socket) {
    return qfs
      .exists(socket)
      .then((exist) => {
        if (exist) {
          return qfs.remove(socket);
        }
      });
  },

  _listen(socket) {
    return defer((resolve, reject) => {
Example #4
0
File: pid.js Project: lucasfais/azk
 kill() {
   if (this.running) {
     process.kill(this.pid, 'SIGTERM');
   }
   return Q();
 }
Example #5
0
    });
  },

  stop() {
    if (this.isRunnig()) {
      log.debug("call to stop balancer");
      return Tools.async_status("balancer", this, function* (change_status) {
        yield Q.all([
          this._stop_system('balancer-redirect', change_status),
          this._stop_system('dns', change_status),
        ]);
        yield this._stop_sub_service("hipache", change_status);
        yield this._stop_sub_service("memcached", change_status);
      });
    } else {
      return Q();
    }
  },

  isRunnig() {
    return (
      (this.hipache && this.hipache.running) ||
      (this.memcached && this.memcached.running)
    );
  },

  _removeEntry(entries, backend) {
    return _.filter(entries, (entry) => { return entry != backend; });
  },

  _getSystem(system) {
Example #6
0
 retry_if: () => { return Q(true); }
Example #7
0
              retry: retry,
              timeout: timeout,
              hostname: system.url.underline,
            }))
          );
        } else {
          yield this.throwRunError(system, container, null, true);
        }
      }

      return true;
    });
  },

  throwRunError(system, container, data = null, stop = false) {
    data = data ? Q(data) : container.inspect();
    return data.then((data) => {
      // Get container log
      var promise = container.logs({stdout: true, stderr: true}).then((stream) => {
        return defer((resolve, reject) => {
          var acc = '';
          var stdout = {
            write(data) { acc += data.toString(); }
          };
          container.modem.demuxStream(stream, stdout, stdout);
          stream.on('end', () => { resolve(acc); });
          setTimeout(() => { reject(new Error("timeout")); }, 4000);
        });
      });

      return promise.then((log) => {