Skip to content

Instantly share code, notes, and snippets.

@marzdgzmn
marzdgzmn / ansible
Last active January 23, 2019 04:07
- name: Conifgure named.options
template: src=named.options.j2 dest=/etc/named/named.options
notify:
- restart named-chroot
tags:
- named_options
auto lo
iface lo inet loopback
iface lo inet6 loopback
auto eno1
iface eno1 inet manual
pre-up ip l s $IFACE mtu 9000
auto eno1.850
iface eno1.850 inet statis
module A
module B
class Manager
include Module A::B::Notification
at_exit do
if $ERROR_INFO
error = {
timnestamp: Time.now,
message: $ERROR_INFO.message,
thread_pool = Concurrent::FixedThreadPool.new(10, max_queue:50)
until job_list.empty?
job = job_list.shift
Concurrent::Promises.future(executor: thread_pool) { MyJob.run(job) }.
rescue{ |e| puts e }.result
end
module Foo
module Bar
LOG = Logger.new()
def self.run()
thread_pool = Concurrent::FixedThreadPool.new(10, max_queue:50)
until mirrors.empty?
mirror = mirror.shift
Concurrent::Future.execute(executor: thread_pool) { Sync.run() }
end
at_exit do
puts 'sync at_exit'
if $ERROR_INFO
puts 'yeaah'
error = {
timestamp: Time.now,
message: $ERROR_INFO.message,
backtrace: $ERROR_INFO.backtrace,
}
LOG.error YAML.dump(error)
module Notification
def self.send_email(msg)
Pony.mail({
:to => Rise::MirrorManager.configuration.admin_email,
:from => "MirrorManager@#{Socket.gethostname}",
:via => :smtp,
:via_options => {
:address => 'aspmx.l.google.com',
:port => 25,
:domain => Socket.gethostname
module Foo
module Bar
LOG = Logging.app_logger
def self.run(intervals)
mirrors = retrieve_mirrors(intervals)
run_syncs(mirrors)
end
def self.run_syncs(mirrors)
mirror_db = Rise::MirrorManager.configuration.database
unless File.exist?(mirror_db)
SQLite3::Database.new(mirror_db) do |db|
db.execute %{
CREATE TABLE IF NOT EXISTS mirrors(
mirror_id INTEGER NOT NULL PRIMARY KEY,
name TEXT NOT NULL UNIQUE
);}
db.execute %{
module Foo
module Bar
module Database
DB = Foo::Bar.configuration.database
def update_result(name, status)
# do something
end
end
end