1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/lib/puma/plugin/tmp_restart.rb
Nate Berkopec 4c85facff3
Test cleanup and parallelization (#1846)
* Add frozen string literal everywhere it wasnt already

* Enforce stopgap for tests

* Small amount of integration test cleanup

* Parallelize and freeze Test_app_status

* Big cleanup for test_binder

* Whitespace fix
2019-07-16 18:53:28 -04:00

36 lines
735 B
Ruby

# 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