rufus-scheduler 수정
This commit is contained in:
parent
def8d28c3b
commit
9ca6e10ac1
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="development.sqlite3" uuid="d3ab71a5-ebb0-4573-9e48-bc4bd013b015">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/storage/development.sqlite3</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/app/controllers/schedules_controller.rb" dialect="GenericSQL" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -30,6 +30,14 @@ class SchedulesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def reset
|
||||
Schedule.delete_all
|
||||
ActiveRecord::Base.connection.execute("DELETE FROM sqlite_sequence WHERE name='schedules'")
|
||||
Rails.application.load_seed
|
||||
|
||||
redirect_to schedules_path, notice: "스케줄이 초기화되었습니다."
|
||||
end
|
||||
|
||||
def schedule_edit
|
||||
@schedule = Schedule.order(:hour, :minute)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ module Modbus
|
|||
class PollingService
|
||||
class << self
|
||||
def start
|
||||
return if defined?(@scheduler) && @scheduler.jobs.any?
|
||||
return if @scheduler && @scheduler.jobs.any?
|
||||
|
||||
puts "[#{Time.current}] Modbus polling service 시작됨 (Rufus)"
|
||||
@scheduler = Rufus::Scheduler.new
|
||||
@scheduler ||= Rufus::Scheduler.new
|
||||
|
||||
@scheduler.cron "0 * * * * *" do
|
||||
now = Time.now
|
||||
|
|
@ -22,6 +22,7 @@ module Modbus
|
|||
def stop
|
||||
if defined?(@scheduler)
|
||||
@scheduler.shutdown(:kill)
|
||||
@scheduler = nil
|
||||
puts "[#{Time.current}] Modbus polling service 중지됨"
|
||||
else
|
||||
puts "[#{Time.current}] Scheduler 인스턴스 없음"
|
||||
|
|
@ -29,7 +30,7 @@ module Modbus
|
|||
end
|
||||
|
||||
def running?
|
||||
defined?(@scheduler) && @scheduler.jobs.any?
|
||||
@scheduler && @scheduler.jobs.any?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -39,9 +39,15 @@
|
|||
<%= submit_tag "업데이트", class: "btn bg-primary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="flex p-4">
|
||||
<%= button_to "초기화", reset_schedules_path,
|
||||
method: :post,
|
||||
data: { turbo_confirm: "정말 초기화하시겠습니까? 모든 스케줄 데이터가 삭제됩니다." },
|
||||
class: "btn bg-danger" %>
|
||||
</div>
|
||||
<div class="flex p-4">
|
||||
<%= button_to "추가하기", open_modals_path(type: "add_schedule"),
|
||||
class: "btn btn-default",
|
||||
class: "btn bg-default-slate",
|
||||
data: {
|
||||
turbo_method: :post,
|
||||
turbo_frame: "modals"
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :schedules do
|
||||
collection do
|
||||
post "reset"
|
||||
get "schedule_edit"
|
||||
post "schedule_edit_update"
|
||||
end
|
||||
|
|
@ -24,8 +25,6 @@ Rails.application.routes.draw do
|
|||
collection do
|
||||
post "start"
|
||||
post "stop"
|
||||
get "schedule_edit"
|
||||
post "schedule_edit_update"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue