~singpolyma/sgx-jmp

a20669a877467b53836b213e0bc2faaad01ebb08 — Stephen Paul Weber 11 months ago 945b17d
Load plans to db
1 files changed, 11 insertions(+), 0 deletions(-)

M sgx_jmp.rb
M sgx_jmp.rb => sgx_jmp.rb +11 -0
@@ 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]