diff --git a/app/views/shared/_nav.html.erb b/app/views/shared/_nav.html.erb index fcd47b9..6dd36cb 100644 --- a/app/views/shared/_nav.html.erb +++ b/app/views/shared/_nav.html.erb @@ -1,38 +1,38 @@ diff --git a/config/application.rb b/config/application.rb index 1892613..4908552 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,45 +1,45 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' # Production doesn't use bundler # you've limited to :test, :development, or :production. if ENV['RAILS_ENV'] != 'production' Bundler.require(*Rails.groups) else # Dependencies to load before starting rails in production require 'devise' require 'jquery-rails' require 'beaneater' end -module Base +module WebDNS class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. config.time_zone = 'Europe/Athens' # Store/Read localtime from the database config.active_record.default_timezone = :local config.active_record.schema_format = :sql # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de config.autoload_paths << Rails.root.join('lib') config.x = {} end def self.settings Application.config.x end def self.bean @bean ||= Bean::Client.new( YAML.load_file(Rails.root.join('config', 'beanstalk.yml'))[Rails.env].symbolize_keys[:host] ) end end diff --git a/config/initializers/00_settings.rb b/config/initializers/00_settings.rb index 692cada..d92c3e0 100644 --- a/config/initializers/00_settings.rb +++ b/config/initializers/00_settings.rb @@ -1,27 +1,25 @@ -WebDNS = Base - WebDNS.settings[:soa_defaults] = { primary_ns: 'ns1.example.com', contact: 'domainmaster@example.com', serial: 1, refresh: 10_800, retry: 3600, expire: 604_800, nx: 3600 } WebDNS.settings[:default_ns] = [ 'ns1.example.com', 'ns2.example.com' ] WebDNS.settings[:serial_strategy] = Strategies::Date WebDNS.settings[:prohibit_records_types] = [] WebDNS.settings[:contact_mail] = 'webdns@example.com' WebDNS.settings[:mail_from] = 'webdns@example.com' WebDNS.settings[:admin_group] = 'admin' # Allow local overrides local_settings = File.expand_path('../../local_settings.rb', __FILE__) require_relative local_settings if File.exist?(local_settings) diff --git a/lib/bean/worker.rb b/lib/bean/worker.rb index 61e7dd6..41f2c99 100644 --- a/lib/bean/worker.rb +++ b/lib/bean/worker.rb @@ -1,77 +1,77 @@ require 'singleton' module Bean class Worker include Singleton TIMEOUT = 5 attr_accessor :job # Start consuming jobs. def self.work instance.work end # Start consuming jobs. # # Handles reconnects. def work register_signals watch rescue Beaneater::NotConnected - Base.beanstalk_reconnect! + WebDNS.bean.reconnect! end # Graceful stop the worker. # # If no job is running stops immediately. def stop if job.nil? exit else @stop = true end end private def stop? # rubocop:disable Style/TrivialAccessors @stop end def register_signals trap('INT') { stop } trap('TERM') { stop } end def watch loop do procline('watching') break if stop? process_job end rescue Beaneater::TimedOutError retry end def process_job - self.job = Base.bean.reserve(TIMEOUT) + self.job = WebDNS.bean.reserve(TIMEOUT) log_job job.delete ensure self.job = nil end def log_job procline("working on jobid=#{job.id} #{job.body}") Rails.logger.warn(job_id: job.id, job_body: job.body.to_s) end def procline(line) $0 = "bean-#{line}" end end end