Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puma delete pid file in cluster mode #444

Closed
le0pard opened this issue Jan 23, 2014 · 1 comment
Closed

Puma delete pid file in cluster mode #444

le0pard opened this issue Jan 23, 2014 · 1 comment

Comments

@le0pard
Copy link

le0pard commented Jan 23, 2014

I have:

ruby 2.1.0
puma 2.7.1

Config:

#!/usr/bin/env puma
directory '/var/www/falcon-web/current'

environment 'staging'

daemonize true
quiet

pidfile '/var/www/falcon-web/shared/pids/puma.pid'

stdout_redirect '/var/www/falcon-web/shared/log/puma_stdout.log', '/var/www/falcon-web/shared/log/puma_stderr.log'

threads 0, 8

bind 'unix:///var/www/falcon-web/shared/tmp/sockets/puma.sock'
state_path '/var/www/falcon-web/shared/tmp/sockets/puma.state'

workers 2

preload_app!

on_worker_boot do
  ActiveRecord::Base.connection_pool.disconnect!

  ActiveSupport.on_load(:active_record) do
    config = Rails.application.config.database_configuration[Rails.env]
    ActiveRecord::Base.establish_connection(config)
  end
end

After start of puma by command bundle exec puma -C /var/www/falcon-web/current/config/puma.rb it remove pid file.

Added logging in parts of code (puma-2.7.1/lib/puma/cli.rb):

 def run
      begin
        parse_options
      rescue UnsupportedOption
        exit 1
      end

      if dir = @options[:directory]
        Dir.chdir dir
      end

      set_rack_environment

      if clustered?
        @events = PidEvents.new STDOUT, STDERR
        @options[:logger] = @events

        @runner = Cluster.new(self)
      else
        @runner = Single.new(self)
      end

      setup_signals

      @status = :run

      @runner.run

      case @status
      when :halt
        log "* Stopping immediately!"
      when :run, :stop
        graceful_stop
      when :restart
        log "* Restarting..."
        @runner.before_restart
        restart!
      when :exit
        # nothing
      end

    ensure
      $stdout.puts "delete_pidfile ensure" ### THIS IS MY LINE
      delete_pidfile
    end

What I get in output of bundle exec puma -C /var/www/falcon-web/current/config/puma.rb:

$ bundle exec puma -C /var/www/falcon-web/current/config/puma.rb'
[13838] Puma starting in cluster mode...
[13838] * Version 2.7.1, codename: Earl of Sandwich Partition
[13838] * Min threads: 0, max threads: 8
[13838] * Environment: staging
[13838] * Process workers: 2
[13838] * Preloading application
[13838] * Listening on unix:///var/www/falcon-web/shared/tmp/sockets/puma.sock
[13838] * Daemonizing...
delete_pidfile ensure
delete_pidfile ensure

How is it possible to fix this issue?

@le0pard
Copy link
Author

le0pard commented Jan 25, 2014

Thanks, looks like it help 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant