E
E
Evgeny Trofimov2019-04-15 17:27:19
Node.js
Evgeny Trofimov, 2019-04-15 17:27:19

How to run a function in a separate process?

There is a runMe.js file where

export default async function handler(props) {
  // some hard work
  return someData;
}

I want to run this file in a separate process, passing props there and getting someData, i.e.
const result = await runInAnotherProcess('./runMe.js', props)

How can this be checked?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2019-04-15
@Vlad_IT

There are Workers, they run in a separate thread (not a process) https://nodejs.org/api/worker_threads.html
You can run a separate module through child_process.fork

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question