Sha256: b7f56122cfe8ab8065afde602c9d9180e7bfb5e2fed35f526ca2e20332ea9016

Contents?: true

Size: 705 Bytes

Versions: 14

Compression:

Stored size: 705 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

14 entries across 12 versions & 2 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/puma-3.8.2/lib/puma/plugin/tmp_restart.rb
tdiary-5.0.5 vendor/bundle/gems/puma-3.9.1/lib/puma/plugin/tmp_restart.rb
tdiary-5.0.5 vendor/bundle/gems/puma-3.8.2/lib/puma/plugin/tmp_restart.rb
puma-3.9.1-java lib/puma/plugin/tmp_restart.rb
puma-3.9.1 lib/puma/plugin/tmp_restart.rb
puma-3.9.0-java lib/puma/plugin/tmp_restart.rb
puma-3.9.0 lib/puma/plugin/tmp_restart.rb
tdiary-5.0.4 vendor/bundle/gems/puma-3.8.2/lib/puma/plugin/tmp_restart.rb
puma-3.8.2-java lib/puma/plugin/tmp_restart.rb
puma-3.8.2 lib/puma/plugin/tmp_restart.rb
puma-3.8.1-java lib/puma/plugin/tmp_restart.rb
puma-3.8.1 lib/puma/plugin/tmp_restart.rb
puma-3.8.0-java lib/puma/plugin/tmp_restart.rb
puma-3.8.0 lib/puma/plugin/tmp_restart.rb