From 98082a17d506eb9aab72f8d222d519d08a3c714e Mon Sep 17 00:00:00 2001 From: Chris Cherry Date: Mon, 4 May 2009 15:01:42 -0700 Subject: [PATCH] Add process name 'tag' functionality. Easier to distinguish thin daemons from eachother in process listing --- lib/thin/runner.rb | 1 + lib/thin/server.rb | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/thin/runner.rb b/lib/thin/runner.rb index 21dab052..06dae90b 100644 --- a/lib/thin/runner.rb +++ b/lib/thin/runner.rb @@ -87,6 +87,7 @@ def parser "(default: #{@options[:pid]})") { |file| @options[:pid] = file } opts.on("-u", "--user NAME", "User to run daemon as (use with -g)") { |user| @options[:user] = user } opts.on("-g", "--group NAME", "Group to run daemon as (use with -u)") { |group| @options[:group] = group } + opts.on( "--tag NAME", "Additional text to display in process listing") { |tag| @options[:tag] = tag } opts.separator "" opts.separator "Cluster options:" diff --git a/lib/thin/server.rb b/lib/thin/server.rb index b621e064..978285a1 100644 --- a/lib/thin/server.rb +++ b/lib/thin/server.rb @@ -59,7 +59,10 @@ class Server # Application (Rack adapter) called with the request that produces the response. attr_accessor :app - + + # A tag that will show in the process listing + attr_accessor :tag + # Backend handling the connections to the clients. attr_accessor :backend @@ -103,6 +106,9 @@ def initialize(*args, &block) end end + # Set tag if needed + self.tag = options[:tag] + # Try to intelligently select which backend to use. @backend = select_backend(host, port, options) @@ -188,7 +194,8 @@ def config # Name of the server and type of backend used. # This is also the name of the process in which Thin is running as a daemon. def name - "thin server (#{@backend})" + buffer = "thin server (#{@backend})" + buffer << " [#{tag}]" unless tag.nil? || tag.empty? end alias :to_s :name