stjohnjohnson / smartthings-mqtt-bridge

Bridge between SmartThings and MQTT
https://hub.docker.com/r/stjohnjohnson/smartthings-mqtt-bridge/
MIT License
363 stars 242 forks source link

Set process.title #204

Open mschwartz opened 5 years ago

mschwartz commented 5 years ago

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 commented 5 years ago

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.