Esempio n. 1
0
      return co(function *() {
        var servicePath = (options.name[0] === '/' ? options.name : path.resolve(BASE_DIR, options.name))  + '.js';
        var stat = fs.lstatSync(servicePath);
        var version = stat.mtime.getTime();

        var putService = function() {
          options.initialize = require(servicePath);
          options.version = options.version || version;
          // if (this.context.isWorker) {
          //   initialize.useWorker = false;
          // }
          return this.put(options.name, this.create(options));
        };


        var service = this.values[options.name];
        if (!this.values[options.name]) {
          service = putService.call(this);
        } else if (require.cache[servicePath]) {
          service = this.values[options.name];
          if (service.version !== version) {
            var oldStatus = service.status;
            delete require.cache[servicePath];
            yield service.destroy();

            service = putService.call(this);
            if (oldStatus === Service.STARTED) {
              yield service.start();
            }
          }
        }

        return service;
      }.bind(this));
Esempio n. 2
0
 const countries = files.filter(file => fs.lstatSync(path.join(__dirname, `banks/${file}`)).isDirectory());