Browse Source

fix definable_listeners

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

14
lib/live/definable.rb

@ -1,6 +1,6 @@
require 'dotenv' require 'dotenv'
DEFINABLE_THREAD_GROUP ||= ThreadGroup.new # rubocop:disable Lint/OrAssignmentToConstant
# DEFINABLE_THREAD_GROUP ||= ThreadGroup.new
DEFINABLE_LISTENERS ||= [] # rubocop:disable Lint/OrAssignmentToConstant DEFINABLE_LISTENERS ||= [] # rubocop:disable Lint/OrAssignmentToConstant
module Live module Live
@ -97,19 +97,15 @@ module Live
end end
def start_listener 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_LISTENERS.clear
DEFINABLE_THREAD_GROUP.list.each(&:kill)
DEFINABLE_THREAD_GROUP.add(Thread.new do
listener = Listen.to(Rails.root, only: /^\.env\.?/) do listener = Listen.to(Rails.root, only: /^\.env\.?/) do
@@class_origin.reload_from_env @@class_origin.reload_from_env
rescue StandardError
nil
rescue StandardError => e
logger.error('unable to reload from env', e)
end end
DEFINABLE_LISTENERS << listener
listener.start listener.start
end)
DEFINABLE_LISTENERS << listener
end end
def typed_value(type, raw, default) 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]) clazz = colorize("#{exc.class}\n", color_map[:fatal])
message = colorize(exc.message.chomp(''), color_map[:error]) message = colorize(exc.message.chomp(''), color_map[:error])
backtrace = exc.backtrace backtrace = exc.backtrace
stack = Helper.stackisize(*backtrace)
stack = Semantic::Helper.stackisize(*backtrace)
["#{clazz}#{message}", stack].compact.join("\n") ["#{clazz}#{message}", stack].compact.join("\n")
end end

Loading…
Cancel
Save