Sha256: 7d34dc3a4888b5324fe53991b00e6d8419454f79c98638ae0076db9ae9f993b9

Contents?: true

Size: 760 Bytes

Versions: 3

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true
require "concurrent/timer_task"

require "caddy/version"
require "caddy/task_observer"
require "caddy/cache"

module Caddy
  class << self
    attr_accessor :error_handler
  end

  @started_pid = nil
  @caches = Hash.new { |h, k| h[k] = Caddy::Cache.new(k) }

  def self.[](k)
    @caches[k]
  end

  def self.caches
    @caches
  end

  def self.start
    if !@started_pid
      @started_pid = $$
    elsif @started_pid && $$ != @started_pid
      raise "Please run `Caddy.start` *after* forking, as the refresh thread will get killed after fork"
    end

    @caches.freeze

    @caches.values.each(&:start).all?
  end

  def self.stop
    @caches.values.each(&:stop).all?
  end

  def self.restart
    stop
    start
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
caddy-1.5.4 lib/caddy.rb
caddy-1.5.3 lib/caddy.rb
caddy-1.5.2 lib/caddy.rb