Setup a worker which has `require()` defined
@ignore
177997
function(workerModuleId) {
   var moduleRoot = uri.resolve(document.location.href, window.require.getModuleRoot());
   var initialScripts = [];
   Array.prototype.slice.apply(document.getElementsByTagName('script'), [0]).forEach(function(script) {
      if (script.src) {
         initialScripts.push(script.src);
      }
   });

   var URL = window.URL || window.webkitURL;
   var prefixString = workerPrefix.toString();
   // don't be afraid...
   prefixString = prefixString.substring(prefixString.indexOf("{") + 1, prefixString.lastIndexOf("}"));
   var blob = new Blob([
      'var __scripts = ["' + initialScripts.join('","') + '"];',
      prefixString,
      ';self.require.setModuleRoot("' + moduleRoot + '");',
      'self.require.run("'+ workerModuleId +'");'
   ], {type: 'application\/javascript'});

   var blobURL = URL.createObjectURL(blob);
   return new Worker(blobURL);
}
859861
function setupByCopy() {
    let task_dir;
    let required_tasks;

    try {
        const config = require(path.join(process.cwd(), 'project.config'));
        required_tasks = config.required_tasks;
        if (!required_tasks) {
            throw Error('no task required.');
        }
        task_dir = config.dir.task;
        if (!task_dir) {
            throw Error('task directory not defined.');
        }
    } catch (error) {
        console.warn(error);
        process.exit(0);
    }

    const dstTaskDir = path.join(process.cwd(), task_dir);
    if (!fs.existsSync(dstTaskDir)) {
        // create tasks dir
        fs.mkdirSync(dstTaskDir);
    }

    required_tasks.forEach((task) => {
        const src = path.join(__dirname, 'tasks', task);
        const dst = path.join(dstTaskDir, task);
        if (fs.existsSync(src)) {
            if (fs.existsSync(dst)) {
                fs.unlinkSync(dst);
            }
            fs.writeFileSync(dst, fs.readFileSync(src).toString());
        } else {
            console.error('task not found: ' + task);
            process.exit(1);
        }
    });
}
686451
function(options)
    {
        return new Promise( (resolve, reject) =>
        {
            if (options)
            {
                options.logger.info('[PROGENIC] Starting "%s" daemon with %s workers...', options.name, options.workers);
                options.logger.info('[PROGENIC] [from "%s"]', options.main);

                // Write the PID file:
                helpers.writePidFile(options.name, options.devMode, options.logger);

                cluster.setupMaster(
                {
                    exec: path.join(__dirname, 'worker.js'),
                    args: [options.main, process.env.INSTANCE_NAME],
                    silent: true
                });

                const promises = [];

                let count = options.workers;

                while (count-- > 0)
                {
                    options.logger.info('[PROGENIC] Creating  worker #%s...', (options.workers - count));

                    promises.push(helpers.forkWorker(options.name, options.devMode, options.logger, options.logsBasePath, options.checkPingsEnabled));
                }

                Promise.all(promises)
                .then(resolve)
                .catch(reject);
            }
            else
            {
                reject(new Error('Missing options'));
            }
        });
    }
176885
function requireNJS() {
  try {
    var module = ru(this.path);
  } catch(o_O) {
    console.error(o_O);
    return internalServerError.call(this, o_O);
  }
  module.onload(
    this.request,
    this.response,
    this
  );
}
1218048
function lazy(arg) {
  var conf = this.configure();
  var action = arg.action();
  if(!conf.command.dir || action !== undefined) return false;
  var file = path.join(conf.command.dir, getModulePath.call(this, arg))
  try{
    action = require(file);
    if(typeof action !== 'function') {
      return this.raise(this.errors.ECMD_TYPE, [file]);
    }
    arg.action(action);
  }catch(e) {
    return this.raise(this.errors.ECMD_REQUIRE, [file, e.message], e);
  }
}
360996
function setup(context) {
  if (GLOBAL.config) {
    console.log('already configured');
    console.trace();
    return;
  }
  if (!context) {
    context = require('./config.js');
  }

  GLOBAL.config = context.config;

  var svc = { pubsub: pubsub, auth: auth, indexer: indexer, pageCache: pageCache };

  GLOBAL.svc = svc;
  auth.setupUsers(GLOBAL, context.logins);
}
370249
function(required, done) {
        if (arguments.length < 1 || required) {
          grunt.log.writeln('\nnpm install...');
          // Run npm install in project's directory
          grunt.util.spawn({cmd: 'npm', args: ['install'],
                            opts: {cwd: init.destpath, stdio: 'inherit'}},
              function(error, result, code) {
                if (done) {
                  done();
                }
              });
        } else if (done) {
          done();
        }
      }
187284
protected function worker()
    {
        // Bootstrap
        $this->addLogging();

        // Run this stuff as long as the worker is running
        while (true) {
            $this->fire();
            Cache::forever($this->HEARTBEAT_WORKER_KEY, time());
            sleep($this->WORKER_SLEEP_SECS);
        }
    }
341046
function create_require (env) {
  function require (id) {
    // `require('a@0.0.0')` is prohibited.
    prohibit_require_id_with_version(id);

    // When `require()` another module inside the factory,
    // the module of depdendencies must already been created
    var module = get_module(id, env, true);
    return get_exports(module);
  }

  // @param {string} id Module identifier.
  // Since 4.2.0, we only allow to asynchronously load a single module
  require.async = function(id, callback) {
    if (callback) {
      // `require.async('a@0.0.0')` is prohibited
      prohibit_require_id_with_version(id);
      var module = get_module(id, env);

      // If `require.async` a foreign module, it must be a main entry
      if (!module.main) {

        // Or it should be a module inside the current package
        if (module.n !== env.n) {
          // Otherwise, we will stop that.
          return;
        }
        module.a = true;
      }

      use_module(module, callback);
    }
  };

  // @param {string} path
  require.resolve = function (path) {
    return NEURON_CONF.resolve(parse_id(path, env).id);
  };

  return require;
}
604368
function setup(check) {
  if (!check) {
    throw new Error('Data to match is not defined')
  } else if (!check.jsonBody) {
    throw new Error('jsonBody is not defined')
  } else if (!check.jsonTest) {
    throw new Error('jsonTest is not defined')
  }

  // define the defaults
  const defaults = {
    isNot: false,
    path: undefined,
    // jsonBody will be present
    // jsonTest will be present
  }

  // merge the passed in values with the defaults
  return _.merge(defaults, check)
}
895103
def setupWorkerTransition():
    """"""

    default_warn_method = getWarningMethod()

    def custom_warn_method(message, category, stacklevel):
        if stacklevel is not None:
            stacklevel += 1
        if _WORKER_WARNING_MARK in message:
            # Message contains our mark - it's Worker API Renaming warning,
            # issue it appropriately.
            message = message.replace(_WORKER_WARNING_MARK, "")
            warnings.warn(
                DeprecatedWorkerNameWarning(message), message, stacklevel)
        else:
            # Other's warning message
            default_warn_method(message, category, stacklevel)

    setWarningMethod(custom_warn_method)
1056324
function preload() {
		var path = config.gulpFiles;

		if (/^[^\/]/.test(path)) {
			path = config.basePath + '/' + path;
		}

		glob.sync(path + '/*/*.js').map(function(file) {
			return file.replace(path, '').split('/').filter(function(split) {
				return !!split;
			});
		}).forEach(function(file) {
			register(
				file[0],
				file[file.length - 1].replace(/\.js$/, ''),
				require(path + '/' + file.join('/'))
			);
		});

		console.log(chalk.cyan('Devour initialized'));

		if (config.verbose) {
			['task', 'pipe'].forEach(function(what) {
				console.log(
					'  - available %ss: %s',
					what,
					what in definitions ? chalk.green(Object.keys(definitions[what]).join(', ')) : chalk.yellow('none')
				);
			});
			console.log('');
		}
	}
1035516
protected function configureSwooleServer()
    {
        $config = $this->app->make('config');
        $options = $config->get('swoole_http.server.options');

        // only enable task worker in websocket mode and for queue driver
        if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) {
            unset($options['task_worker_num']);
        }

        static::$server->set($options);
    }
1049198
function requireProxy(path) {
    reset();
    currentModule.require = nodeRequire;
    return nodeRequire.call(currentModule, path);  // node's require only works when "this" points to the module
}
567303
def setWorkerInfo(self, hostname, workerAmount, origin):
        """"""

        scoop.logger.debug('Initialising {0}{1} worker {2} [{3}].'.format(
            "local" if hostname in utils.localHostnames else "remote",
            " origin" if origin else "",
            self.workersLeft,
            hostname,
            )
        )

        add_args, add_kwargs = self._setWorker_args(origin)
        self.workers[-1].setWorker(*add_args, **add_kwargs)
        self.workers[-1].setWorkerAmount(workerAmount)
970991
function Master() {
  EventEmitter.call(this);

  if (config.workerMessageHandler) {
    this.workerMessageHandler = require(config.workerMessageHandler);
  }

  if (!_.isFunction(this.workerMessageHandler)) {
    this.workerMessageHandler = function () {};
  }

  this.workerMessageHandler.bind(this);
}
987740
def setup(basepath=DEFAULT_BASEPATH):
    """"""

    module_version = os.environ.get('MODULE_VERSION', DEFAULT_VERSION)
    moduleshome = os.path.join(basepath, module_version)

    # Abort if MODULESHOME does not exist
    if not os.path.isdir(moduleshome):
        print('payu: warning: MODULESHOME does not exist; disabling '
              'environment modules.')
        os.environ['MODULESHOME'] = ''
        return

    os.environ['MODULE_VERSION'] = module_version
    os.environ['MODULE_VERSION_STACK'] = module_version
    os.environ['MODULESHOME'] = moduleshome

    if 'MODULEPATH' not in os.environ:
        module_initpath = os.path.join(moduleshome, 'init', '.modulespath')
        with open(module_initpath) as initpaths:
            modpaths = [
                line.partition('#')[0].strip()
                for line in initpaths.readlines() if not line.startswith('#')
            ]

        os.environ['MODULEPATH'] = ':'.join(modpaths)

    os.environ['LOADEDMODULES'] = os.environ.get('LOADEDMODULES', '')

    # Environment modules with certain characters will cause corruption
    # when MPI jobs get launched on other nodes (possibly a PBS issue).
    #
    # Bash processes obscure the issue on Raijin, since it occurs in an
    # environment module function, and bash moves those to the end of
    # the environment variable list.
    #
    # Raijin's mpirun wrapper is a bash script, and therefore "fixes" by doing
    # the shuffle and limiting the damage to other bash functions, but some
    # wrappers (e.g. OpenMPI 2.1.x) may not be present.  So we manually patch
    # the problematic variable here.  But a more general solution would be nice
    # someday.

    if 'BASH_FUNC_module()' in os.environ:
        bash_func_module = os.environ['BASH_FUNC_module()']
        os.environ['BASH_FUNC_module()'] = bash_func_module.replace('\n', ';')