스케쥴러 시작/정기 기능 추가
This commit is contained in:
@@ -2,9 +2,9 @@ module Modbus
|
||||
class PollingService
|
||||
class << self
|
||||
def start
|
||||
return if @thread&.alive?
|
||||
return if $modbus_polling_threads.any?(&:alive?)
|
||||
|
||||
@thread = Thread.new do
|
||||
thread = Thread.new do
|
||||
puts "[#{Time.current}] Modbus polling service 시작됨"
|
||||
last_logged_hour = nil
|
||||
loop do
|
||||
@@ -32,14 +32,17 @@ module Modbus
|
||||
end
|
||||
end
|
||||
end
|
||||
$modbus_polling_threads << thread
|
||||
end
|
||||
|
||||
def stop
|
||||
if @thread
|
||||
@thread.exit
|
||||
@thread = nil
|
||||
puts "[#{Time.now}] Modbus polling service 중지됨"
|
||||
end
|
||||
$modbus_polling_threads.each { |t| t.kill if t.alive? }
|
||||
$modbus_polling_threads.clear
|
||||
puts "[#{Time.now}] Modbus polling service 중지됨"
|
||||
end
|
||||
|
||||
def running?
|
||||
$modbus_polling_threads.any?(&:alive?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user