How to use the threads.config function in threads

To help you get started, we’ve selected a few threads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github formio / formio / src / worker / Thread.js View on Github external
'use strict';

const path = require('path');
const Threads = require('threads');
const config = Threads.config;
const Spawn = Threads.spawn;

config.set({
  basepath: {
    node: path.join(__dirname, 'tasks')
  }
});

class Thread {
  constructor(task) {
    this.task = task;

    let options = undefined;
    // Check if debug is an argument.
    if (process.execArgv.reduce((prev, cur) => (prev || cur.indexOf('--debug') !== -1), false)) {
      options = {execArgv: [`--debug=${Math.floor(Math.random() * (65535 - 1025)) + 1024}`]};