-1

I have a rack/ruby application on a server. I run it as follows:

  nohup rackup -o 0.0.0.0 -p 1234 &

In the output of "top" command it appears as simply "ruby"

PID   USERNAME    THR PRI NICE   SIZE    RES STATE    TIME    WCPU COMMAND

98421  my_user123       3  20    0   140M 29576K select   0:29   0.01% ruby

How can I adjust its name in the "top"? What if I run 5 such web apps, how would I distinguish which is which if they're all "ruby"?

Kakki
  • 1
  • 2
  • 1
    `What if I run 5 such web apps, how would I distinguish which is which if they're all "ruby"?` - Well... they'd all have a different PID. – joeqwerty Dec 07 '17 at 03:41
  • @joeqwerty, I said - "how would I know which is which" – Kakki Dec 07 '17 at 04:10

2 Answers2

0

It's not the process name you need to adjust, but your tool.

Press c while top is running, or just start it with -c to see full command lines.

For example, without -c:

12329 error     20   0  618748 202472  19424 S   0.0 20.0   7:49.32 ruby

And with -c:

12329 error     20   0  618748 202472  19424 S   0.0 20.0   7:49.32 ruby /home/error/.rvm/gems/ruby-2.2.7@app/bin/thin start -a ::1 -p 8008
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
0

On systems where it is supported, you can change the name of a process in ruby by assigning to $0 or by using Process.setproctitle (ruby 2.1+).

hobbs
  • 526
  • 3
  • 8