Jeremy Evans
2010-Jul-02 20:50 UTC
[PATCH] Show the current working directory in the proc title
>From 7aec3c7f83430900e91f7df854577f1bac5e7c3a Mon Sep 17 00:00:00 2001From: Jeremy Evans <code at jeremyevans.net> Date: Fri, 2 Jul 2010 13:46:15 -0700 Subject: [PATCH] Show the current working directory in the proc title 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. --- lib/unicorn.rb | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index a7b0646..a764cd7 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -811,8 +811,8 @@ module Unicorn end def proc_name(tag) - $0 = ([ File.basename(START_CTX[0]), tag - ]).concat(START_CTX[:argv]).join('' '') + $0 = ([ File.basename(START_CTX[0]), File.basename(START_CTX[:cwd]), + tag ]).concat(START_CTX[:argv]).join('' '') end def redirect_io(io, path) -- 1.7.0.5
Eric Wong
2010-Jul-02 22:29 UTC
[PATCH] Show the current working directory in the proc title
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) -- Eric Wong
Jeremy Evans
2010-Jul-02 22:50 UTC
[PATCH] Show the current working directory in the proc title
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('' '') end end 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. Thanks, Jeremy
Eric Wong
2010-Jul-05 23:34 UTC
[PATCH] Show the current working directory in the proc title
Jeremy Evans <jeremyevans0 at gmail.com> wrote:> 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.Agreed, thanks Jeremy!>From d7695c25c5e3b1c90e63bf15a5c5fdf68bfd0c34 Mon Sep 17 00:00:00 2001From: Eric Wong <normalperson at yhbt.net> Date: Mon, 5 Jul 2010 23:14:40 +0000 Subject: [PATCH] doc: recommend absolute paths for -c/--config-file Suggested-by: Jeremy Evans ref: http://mid.gmane.org/AANLkTintT4vHGEdueuG45_RwJqFCToHi5pm2-WKDSUMz at mail.gmail.com --- Documentation/unicorn.1.txt | 3 +++ Documentation/unicorn_rails.1.txt | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/unicorn.1.txt b/Documentation/unicorn.1.txt index 24df7ab..c20a570 100644 --- a/Documentation/unicorn.1.txt +++ b/Documentation/unicorn.1.txt @@ -36,6 +36,9 @@ with rackup(1) but strongly discouraged. implemented as a Ruby DSL, so Ruby code may executed. See the RDoc/ri for the *Unicorn::Configurator* class for the full list of directives available from the DSL. + Using an absolute path for for CONFIG_FILE is recommended as it + makes multiple instances of Unicorn easily distinguishable when + viewing ps(1) output. -D, \--daemonize : Run daemonized in the background. The process is detached from diff --git a/Documentation/unicorn_rails.1.txt b/Documentation/unicorn_rails.1.txt index 267e425..f426b07 100644 --- a/Documentation/unicorn_rails.1.txt +++ b/Documentation/unicorn_rails.1.txt @@ -34,8 +34,11 @@ as much as possible. -c, \--config-file CONFIG_FILE : Path to the Unicorn-specific config file. The config file is implemented as a Ruby DSL, so Ruby code may executed. - See the RDoc/ri for the *Unicorn::Configurator* class for the - full list of directives available from the DSL. + See the RDoc/ri for the *Unicorn::Configurator* class for the full + list of directives available from the DSL. + Using an absolute path for for CONFIG_FILE is recommended as it + makes multiple instances of Unicorn easily distinguishable when + viewing ps(1) output. -D, \--daemonize : Run daemonized in the background. The process is detached from -- Eric Wong
Lawrence Pit
2010-Jul-06 02:18 UTC
[PATCH] Show the current working directory in the proc title
The +after_fork+ doc mentions "generally there''s no reason to start Unicorn as a priviledged user". "generally" that may be true, I''d still recommend to run each app as a dedicated user. The added bonus is that it makes it most obvious in ps(1) listings which app a unicorn process belongs to as ''user'' is usually mentioned first. On small terminals the value of --config-file could easily be cut off at the right, still leaving you in the dark. Lawrence> Jeremy Evans <jeremyevans0 at gmail.com> wrote: > >> 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. >> > > Agreed, thanks Jeremy! > > >From d7695c25c5e3b1c90e63bf15a5c5fdf68bfd0c34 Mon Sep 17 00:00:00 2001 > From: Eric Wong <normalperson at yhbt.net> > Date: Mon, 5 Jul 2010 23:14:40 +0000 > Subject: [PATCH] doc: recommend absolute paths for -c/--config-file > > Suggested-by: Jeremy Evans > ref: http://mid.gmane.org/AANLkTintT4vHGEdueuG45_RwJqFCToHi5pm2-WKDSUMz at mail.gmail.com > --- > Documentation/unicorn.1.txt | 3 +++ > Documentation/unicorn_rails.1.txt | 7 +++++-- > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/Documentation/unicorn.1.txt b/Documentation/unicorn.1.txt > index 24df7ab..c20a570 100644 > --- a/Documentation/unicorn.1.txt > +++ b/Documentation/unicorn.1.txt > @@ -36,6 +36,9 @@ with rackup(1) but strongly discouraged. > implemented as a Ruby DSL, so Ruby code may executed. > See the RDoc/ri for the *Unicorn::Configurator* class for the full > list of directives available from the DSL. > + Using an absolute path for for CONFIG_FILE is recommended as it > + makes multiple instances of Unicorn easily distinguishable when > + viewing ps(1) output. > > -D, \--daemonize > : Run daemonized in the background. The process is detached from > diff --git a/Documentation/unicorn_rails.1.txt b/Documentation/unicorn_rails.1.txt > index 267e425..f426b07 100644 > --- a/Documentation/unicorn_rails.1.txt > +++ b/Documentation/unicorn_rails.1.txt > @@ -34,8 +34,11 @@ as much as possible. > -c, \--config-file CONFIG_FILE > : Path to the Unicorn-specific config file. The config file is > implemented as a Ruby DSL, so Ruby code may executed. > - See the RDoc/ri for the *Unicorn::Configurator* class for the > - full list of directives available from the DSL. > + See the RDoc/ri for the *Unicorn::Configurator* class for the full > + list of directives available from the DSL. > + Using an absolute path for for CONFIG_FILE is recommended as it > + makes multiple instances of Unicorn easily distinguishable when > + viewing ps(1) output. > > -D, \--daemonize > : Run daemonized in the background. The process is detached from >