Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not work in nodejs with a worker with dependencies #5

Open
jobo322 opened this issue Jun 29, 2021 · 1 comment
Open

does not work in nodejs with a worker with dependencies #5

jobo322 opened this issue Jun 29, 2021 · 1 comment

Comments

@jobo322
Copy link

jobo322 commented Jun 29, 2021

I'm trying to use a worker comes from a separated file, the code seems like

import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';

import parseSDF from './parseSDF';

export default function processFile(filename) {
  let sdfText = readFileSync(filename, 'utf8');
  let results = parseSDF(sdfText);

  let hoses = [];
  for (let result of results) {
   hoses.push(result);
  }

  writeFileSync(filename.replace('.sdf', '.json'), JSON.stringify(hoses));
}

the code where I use ework seems like

import { Ework } from 'ework';
import workerFunction from 'worker_path';

async function fun() {
  let files = readdirSync(join(__dirname, '../output')).filter((file) =>
    file.match(/sdf$/),
  );
  const workers = new Ework(processFile);
  const result = await workers.execute(join(__dirname, '../output', files[0]));
}

fun();

but when I try to execute a worker it throw an error that 'readFileSync' is not defined.

am I doing something wrong?

@targos
Copy link
Member

targos commented Jun 29, 2021

We do not maintain this project anymore.
I recommend to use piscina if you want this kind of functionality in Node.js: https://github.com/piscinajs/piscina

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants