Browse Source

fix definable_listeners

main
pvincent 3 months ago
parent
commit
b8f56ea969
  1. 22
      lib/live/definable.rb
  2. 2
      lib/semantic/abstract_formatter.rb

22
lib/live/definable.rb

@ -1,6 +1,6 @@
require 'dotenv'
DEFINABLE_THREAD_GROUP ||= ThreadGroup.new # rubocop:disable Lint/OrAssignmentToConstant
# DEFINABLE_THREAD_GROUP ||= ThreadGroup.new
DEFINABLE_LISTENERS ||= [] # rubocop:disable Lint/OrAssignmentToConstant
module Live
@ -97,19 +97,15 @@ module Live
end
def start_listener
DEFINABLE_LISTENERS.each(&:stop) # FIXME: issue on stop after multiple reload!!! Learn mode about listener: #close
DEFINABLE_LISTENERS.each(&:stop)
DEFINABLE_LISTENERS.clear
DEFINABLE_THREAD_GROUP.list.each(&:kill)
DEFINABLE_THREAD_GROUP.add(Thread.new do
listener = Listen.to(Rails.root, only: /^\.env\.?/) do
@@class_origin.reload_from_env
rescue StandardError
nil
end
DEFINABLE_LISTENERS << listener
listener.start
end)
listener = Listen.to(Rails.root, only: /^\.env\.?/) do
@@class_origin.reload_from_env
rescue StandardError => e
logger.error('unable to reload from env', e)
end
listener.start
DEFINABLE_LISTENERS << listener
end
def typed_value(type, raw, default)

2
lib/semantic/abstract_formatter.rb

@ -29,7 +29,7 @@ module Semantic
clazz = colorize("#{exc.class}\n", color_map[:fatal])
message = colorize(exc.message.chomp(''), color_map[:error])
backtrace = exc.backtrace
stack = Helper.stackisize(*backtrace)
stack = Semantic::Helper.stackisize(*backtrace)
["#{clazz}#{message}", stack].compact.join("\n")
end

Loading…
Cancel
Save