[PATCH] Show the current working directory in the proc title

Jeremy Evans jeremyevans0 at gmail.com
Fri Jul 2 18:50:26 EDT 2010

On Fri, Jul 2, 2010 at 3:29 PM, Eric Wong <normalperson at yhbt.net> wrote:
> Jeremy Evans <code at jeremyevans.net> wrote:
>> This is helpful if you run a server with many web apps in separate
>> directories all running unicorn, as it allows you to easily see
>> which processes are tied to which app.
> Hi Jeremy,
> I recommend using absolute paths with -c/--config-file and allowing
> users to opt-in to it (everybody should be using a Unicorn config
> file in production).
> Having an extra working directory path in there hurts people on smaller
> terminals[1].  With -c, users have more control of what their
> command-line looks like without having something forced on them.
> I can't see myself accepting this patch right now for the above reasons.
> On the other hand, I don't see any reason to alter the way proc_name is
> used in the future, so monkey patching here is fine.
> I'm sure there'll always be folks that will want something different in
> $0 (as evidenced by Rack::Contrib::ProcTitle and like).
> [1] - I try to be considerate of on-call folks working from mobile
>      phones or netbooks and/or bad net connections.  There's even
>      a test in test_exec.rb to ensure the help output text can fit
>      in standard 80x24 ANSI terminals.  Personally, I refuse to use
>      a terminals wider than 80 columns (actually, I would've
>      preferred the world standardized on a 64-column wrap)

Fair enough, I realize the patch wasn't for everyone.  I usually
change to the directory first and call unicorn with a relative path,
but that's probably just a bad habit.  It's fairly easy to monkey
patch it in the configuration file if you need it:

class Unicorn::HttpServer
  def proc_name(tag)
    $0 = ([ File.basename(START_CTX[0]), File.basename(START_CTX[:cwd]),
            tag ]).concat(START_CTX[:argv]).join(' ')

I see in the NEWS entry for 0.95.1 that you do recommend an absolute
path for the -c/--config-file option, but it may be beneficial to
mention this in the man page or other parts of the documentation.


More information about the mongrel-unicorn mailing list