Sha256: 18b1293fde362e5ac07a79504ce19446a1d191476d5eceb173ae087d063ae787

Contents?: true

Size: 704 Bytes

Versions: 33

Compression:

Stored size: 704 Bytes

Contents

require 'puma/plugin'

Puma::Plugin.create do
  def start(launcher)
    path = File.join("tmp", "restart.txt")

    orig = nil

    # If we can't write to the path, then just don't bother with this plugin
    begin
      File.write(path, "") unless File.exist?(path)
      orig = File.stat(path).mtime
    rescue SystemCallError
      return
    end

    in_background do
      while true
        sleep 2

        begin
          mtime = File.stat(path).mtime
        rescue SystemCallError
          # If the file has disappeared, assume that means don't restart
        else
          if mtime > orig
            launcher.restart
            break
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
piesync-puma-3.12.6.1 lib/puma/plugin/tmp_restart.rb
piesync-puma-3.12.6 lib/puma/plugin/tmp_restart.rb
puma-3.12.6-java lib/puma/plugin/tmp_restart.rb
puma-3.12.6 lib/puma/plugin/tmp_restart.rb
puma-3.12.5-java lib/puma/plugin/tmp_restart.rb
puma-3.12.5 lib/puma/plugin/tmp_restart.rb
puma-3.12.4-java lib/puma/plugin/tmp_restart.rb
puma-3.12.4 lib/puma/plugin/tmp_restart.rb
puma-3.12.2-java lib/puma/plugin/tmp_restart.rb
puma-3.12.2 lib/puma/plugin/tmp_restart.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/plugin/tmp_restart.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/plugin/tmp_restart.rb
puma-4.0.1-java lib/puma/plugin/tmp_restart.rb
puma-4.0.1 lib/puma/plugin/tmp_restart.rb
puma-4.0.0-java lib/puma/plugin/tmp_restart.rb
puma-4.0.0 lib/puma/plugin/tmp_restart.rb
puma-3.12.1-java lib/puma/plugin/tmp_restart.rb
puma-3.12.1 lib/puma/plugin/tmp_restart.rb
puma-3.12.0-java lib/puma/plugin/tmp_restart.rb
puma-3.12.0 lib/puma/plugin/tmp_restart.rb