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

Set process.title #204

Open
mschwartz opened this issue Jun 11, 2019 · 1 comment
Open

Set process.title #204

mschwartz opened this issue Jun 11, 2019 · 1 comment

Comments

@mschwartz
Copy link

NodeJS allows you to set process.title to an arbitrary string. Doing so sets $0, argv[0], to the title value. The value will show up in ps or top listings instead of "node ./index.js" - even in the docker container version.

This is a trivial request - just set process.title = "smartthings-mqtt-bridge" at the top of server.js.

On a system with a number of microservices running in docker containers, top/ps would show node./index.js for each of them, so you can't look at the top output and see WHICH container is abusing the CPU or RAM...

Ideally, the code would look like:

process.title = process.env.TITLE || "smartthings-mqtt-bridge";

Thanks for this server/repo. It is awesome.

@mschwartz
Copy link
Author

mschwartz commented Jun 11, 2019

https://nodejs.org/api/process.html#process_process_title

process.title#
Added in: v0.1.104

The process.title property returns the current process title (i.e. returns the current value of ps). Assigning a new value to process.title modifies the current value of ps.

When a new value is assigned, different platforms will impose different maximum length restrictions on the title. Usually such restrictions are quite limited. For instance, on Linux and macOS, process.title is limited to the size of the binary name plus the length of the command line arguments because setting the process.title overwrites the argv memory of the process. Node.js v0.8 allowed for longer process title strings by also overwriting the environ memory but that was potentially insecure and confusing in some (rather obscure) cases.

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

1 participant