On Wed, Feb 23, 2011 at 4:32 PM, Clint Pachl <pa...@ecentryx.com> wrote:
> I use Thin (ruby-thin) as the HTTP frontend for my web frameworks.
>
> STARTING/STOPPING:
> $ sudo -u #{USER} thin -C #{THIN_PRODUCTION_CONF} start
> $ sudo -u #{USER} thin -C #{THIN_PRODUCTION_CONF} stop
>
>
> THIN_PRODUCTION_CONF:
> ---
> rackup: config/config.ru
> address: localhost
> port: 3020
> servers: 4
> max_conns: 1024
> max_persistent_conns: 512
> timeout: 30
> environment: production
> pid: tmp/thin-production.pid
> log: log/thin-production.log
> daemonize: true
>
>
> When sending the thin "stop" command, I get the following error on STDOUT:
>
> Stopping server on localhost:3020 ...
> Sending QUIT signal to process 15182 ...
> /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/daemonizing.rb:7:in
> `getpgid': Operation not permitted (Errno::EPERM)
>        from
> /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/daemonizing.rb:7:in
> `running?'
>        from
> /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/daemonizing.rb:118:in
> `send_signal'
>        from /usr/local/lib/ruby/1.8/timeout.rb:67:in `timeout'
>        from
> /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/daemonizing.rb:117:in
> `send_signal'
>        from
> /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/daemonizing.rb:103:in
> `kill'
>        from
>
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/controllers/controller.
rb:87:in
> `stop'
>        from
>
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/controllers/controller.
rb:128:in
> `tail_log'
>        from
>
/usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/controllers/controller.
rb:86:in
> `stop'
>        from
> /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/runner.rb:177:in
> `send'
>        from
> /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/runner.rb:177:in
> `run_command'
>        from
> /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/lib/thin/runner.rb:143:in
> `run!'
>        from /usr/local/lib/ruby/gems/1.8/gems/thin-1.2.7/bin/thin:6
>        from /usr/local/bin/thin:19:in `load'
>        from /usr/local/bin/thin:19
>
>
> Here's a snipped from daemonizing.rb:
>
>  6: def running?(pid)
>  7:    Process.getpgid(pid) != -1
>  8:  rescue Errno::ESRCH
>  9:    false
> 10:  end
>
> As you can see, the ESRCH error is rescued here, which is the other error
> that getpgid(2) can return.
>
>
> Can anyone explain this?

Yes.  The original author is not checking all of the errors he should
be checking.  He should be rescuing Errno::EPERM and returning true, I
think.

Looks like a patch for exactly that was committed in June of last
year:
https://github.com/macournoyer/thin/blob/master/lib/thin/daemonizing.rb#L8

So thin should probably be updated after ports unlocks.  I'll take care of
it.

Jeremy

Reply via email to