Is there a way to view any worker_threads that are currently in use in node.js?

794 views Asked by At

I am looking at worker_threads in node and have a simple endpoint that will create a new worker thread and run a CPU intensive script that takes a long time to run.

app.get('/test', (req, res) => {
    const worker = new Worker('./number-test.js');
    worker.on('message', (data) => {
        res.status(200).json({data});
    });
});

I want to set up a second endpoint that will return information about any workers that are currently active. Is there a way that I can see how many workers are currently in use at any one time?

0

There are 0 answers