Created
February 11, 2017 00:12
-
-
Save bryanp/f86f33081ec86c9eecf199e1d6340353 to your computer and use it in GitHub Desktop.
Pakyow 1.0 Process Reloading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/setup" | |
require "pakyow" | |
require "rack/handler/puma" | |
def run | |
if Process.respond_to?(:fork) | |
@pid = Process.fork do | |
require "./app/setup" | |
Pakyow::App.run(ENV['RACK_ENV']) | |
end | |
else | |
puts "sorry :(" | |
end | |
end | |
run | |
require "listen" | |
listener = Listen.to(".") do |modified, added, removed| | |
Process.kill("INT", @pid) | |
run | |
end.start | |
sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment