chrahunt / quicken

Make Python apps faster
MIT License
7 stars 1 forks source link

Rewrite command-lines visible in ps to align with process roles #2

Open chrahunt opened 5 years ago

chrahunt commented 5 years ago

There are three processes involved in handling of requests: client, server, and handler. The current command lines are:

  1. client: command line matching how it was invoked
  2. server: command line of the client that started the server
  3. handler: same as server

This is pretty unexpected, since most users would assume that the command-line reflects the actual work being done. A more friendly approach would be:

  1. client: (cli client) {command line} - clearly showing the role of the process which can make it easier to identify the correct process to kill (i.e. not this one)
  2. server: (cli server) {server name} - where {server name} is the name passed to the cli_factory decorator, also helps to identify the process
  3. handler: {command line} - this reflects the actual work being done by the process, and is one of the first things that users of a cli would look for if grepping ps output or using pkill. Actually killing the handler process directly would also lead to the most intuitive outcome - the client that is running in the foreground of a shell would exit with the expected return code

Implementation notes:

  1. OpenBSD: unix.stackexchange
  2. Linux: unix.stackexchange - requires root or kernel 3.18 (which is higher than our target RedHat 7.x which has kernel 3.10).
chrahunt commented 5 years ago

We could use python-prctl however it works by overwriting the **argv for a process, which is less elegant than some of the solutions above, and would require us to re-exec with a large-enough command-line to accommodate most use cases.