Navigation Menu

Skip to content

Commit

Permalink
Add process name 'tag' functionality. Easier to distinguish thin daem…
Browse files Browse the repository at this point in the history
…ons from eachother in process listing
  • Loading branch information
Chris Cherry committed May 4, 2009
1 parent ed2325f commit 98082a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/thin/runner.rb
Expand Up @@ -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:"
Expand Down
11 changes: 9 additions & 2 deletions lib/thin/server.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 98082a1

Please sign in to comment.