G
G
gomerIT2022-01-13 23:25:53
linux
gomerIT, 2022-01-13 23:25:53

If you run two different JS scripts through pm2, will they also work in one thread?

I have a normal webserver script and a cron script which in turn executes complex logic. Since Node is running on a 1st thread, I'm worried that the second script will block the thread and the webserver will have to wait for it to complete, thus not responding. So the question was if I run scripts through pm2, how will they work as separate processes as two different programs without interfering with each other? I haven't really delved into the whole scheme yet. I just read somewhere that pm2 can distribute the work of a process across multiple cores.
Or should I look into modules for creating child processes/multithreading in nodeJS?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-01-14
@vabka

pm2 starts new processes every time.
so nothing gets blocked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question