Initial commit

This commit is contained in:
Yaser
2026-08-13 19:50:53 +03:30
commit 38084458fe
879 changed files with 95198 additions and 0 deletions

31
lib/daemons/daemons.rb Normal file
View File

@@ -0,0 +1,31 @@
# encoding: UTF-8
# frozen_string_literal: true
ROOT = File.expand_path('../../..', __FILE__)
require File.join(ROOT, 'config', 'environment')
# default in peatio image
# require File.join(ENV.fetch('RAILS_ROOT'), 'config', 'environment')
raise "Worker name must be provided." if ARGV.size == 0
name = ARGV[0]
worker = "Workers::Daemons::#{name.camelize}".constantize.new
terminate = proc do
puts "Terminating worker .."
worker.stop
puts "Stopped."
end
Signal.trap("INT", &terminate)
Signal.trap("TERM", &terminate)
begin
worker.run
rescue StandardError => e
if worker.is_db_connection_error?(e)
logger.error(db: :unhealthy, message: e.message)
raise e
end
report_exception(e)
end