Languages

Node.js - is it possible to distinguish node instances by some additional parameter?

5 points
Asked by:
Jun-L
963

I am looking for the best way to distinguish Node.js instances on the processes list in a operating system in in a task manager. I run the same script many times that makes it complicated when I look on that list. I run Node.js instances from Java application many times. I need it to be able to select specific process using other application in operating system and monitor it, debug it and kill it if needed. I want to debug specific Node.js instances using IDE by attaching to existing processes.

Any ideas?

2 answers
4 points
Answered by:
Root-ssh
178180

Consider to use environment variables.

e.g.

But, for different operating systems, environment variables are set in different ways and some task managers may do not display them.

0 commentsAdd comment
3 points
Answered by:
Creg
9600

By running Node.js as a sub-process it may be good to use that technique:

Use some Node.js CLI options by setting unique values per instance.

e.g.

Where: 1 means instance id. 

Motivation: some operating systems tools do not display environment variables, e.g. default Task Manager in Microsoft Windows, so it may be good to use command line options.

 

Example source code (Java)

 

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join