module Pakyow::Application::Behavior::Restarting

Handles triggering restarts in the parent process.

Public Instance Methods

touch_restart() click to toggle source
# File lib/pakyow/application/behavior/restarting.rb, line 47
def touch_restart
  FileUtils.mkdir_p(File.join(config.root, "tmp"))
  FileUtils.touch(File.join(config.root, "tmp/restart.txt"))
end

Private Instance Methods

setup_for_restarting() click to toggle source
# File lib/pakyow/application/behavior/restarting.rb, line 54
def setup_for_restarting
  if config.process.restartable
    config.process.watched_paths << File.join(config.src, "**/*.rb")
    config.process.watched_paths << File.join(config.lib, "**/*.rb")

    # FIXME: this doesn't need to be hardcoded, but instead determined
    # from the source location when registered with the environment
    config.process.watched_paths << File.join(config.root, "config/application.rb")

    Thread.new do
      Filewatcher.new(
        config.process.watched_paths,
        exclude: config.process.excluded_paths
      ).watch do |_path, _event|
        touch_restart
      end
    end
  end
end