From a20669a877467b53836b213e0bc2faaad01ebb08 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 8 Feb 2022 10:54:43 -0500 Subject: [PATCH] Load plans to db --- sgx_jmp.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sgx_jmp.rb b/sgx_jmp.rb index a49e5a7..88f8c7a 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -184,6 +184,15 @@ def poll_for_notify(db) }.catch(&method(:panic)) end +def load_plans_to_db! + DB.transaction do + DB.exec("TRUNCATE plans") + CONFIG[:plans].each do |plan| + DB.exec("INSERT INTO plans VALUES ($1)", [plan.to_json]) + end + end +end + when_ready do LOG.info "Ready" BLATHER = self @@ -203,6 +212,8 @@ when_ready do poll_for_notify(conn) end + load_plans_to_db! + EM.add_periodic_timer(3600) do ping = Blather::Stanza::Iq::Ping.new(:get, CONFIG[:server][:host]) ping.from = CONFIG[:component][:jid] -- 2.45.2