Sha256: f77c6876e46d628914fe000e0aab56fabf9e92090e8b05033ffd10f26a38fec7

Contents?: true

Size: 735 Bytes

Versions: 102

Compression:

Stored size: 735 Bytes

Contents

# frozen_string_literal: true

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

102 entries across 99 versions & 6 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/puma-5.2.2/lib/puma/plugin/tmp_restart.rb
puma-5.3.2-java lib/puma/plugin/tmp_restart.rb
puma-5.3.2 lib/puma/plugin/tmp_restart.rb
puma-5.3.1-java lib/puma/plugin/tmp_restart.rb
puma-5.3.1 lib/puma/plugin/tmp_restart.rb
puma-4.3.8-java lib/puma/plugin/tmp_restart.rb
puma-4.3.8 lib/puma/plugin/tmp_restart.rb
puma-5.3.0-java lib/puma/plugin/tmp_restart.rb
puma-5.3.0 lib/puma/plugin/tmp_restart.rb
puma-5.2.2-java lib/puma/plugin/tmp_restart.rb
puma-5.2.2 lib/puma/plugin/tmp_restart.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/puma-5.2.1/lib/puma/plugin/tmp_restart.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/puma-5.1.1/lib/puma/plugin/tmp_restart.rb
puma-5.2.1-java lib/puma/plugin/tmp_restart.rb
puma-5.2.1 lib/puma/plugin/tmp_restart.rb
puma-5.2.0-java lib/puma/plugin/tmp_restart.rb
puma-5.2.0 lib/puma/plugin/tmp_restart.rb
puma-5.1.1-java lib/puma/plugin/tmp_restart.rb
puma-5.1.1 lib/puma/plugin/tmp_restart.rb
puma-5.1.0-java lib/puma/plugin/tmp_restart.rb