Created
August 25, 2016 10:44
-
-
Save marzzz21/fb3a10251343d061e865d8ce55153bfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
require_relative 'workerpool' | |
require_relative 'common' | |
require_relative 'mirrordatabase' | |
require_relative 'watcher' | |
class MirrorSyncDaemon | |
VERSION = "1.1.0" | |
PID_FILE = '/var/run/mirrorsync.pid' | |
LOG_FILE = DAEMON_LOG | |
attr_reader :quit | |
#-------------------------------------------------------------------------- | |
def run! | |
check_pid #check_status | |
daemonize | |
write_pid | |
trap_signals | |
redirect_output | |
log "Running mirror sync" | |
init_db | |
init_workers | |
init_watcher | |
while !quit | |
sleep(2) | |
end | |
log "Killing all sub processes" | |
kill_all_sub_processes | |
log "Exiting mirror sync" | |
end | |
. . . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require_relative '../lib/mirrorsyncdaemon' | |
class MirrorSyncDaemonTest < Mini::Test | |
def test_check_status_checks_PID_FILE | |
@workerpool = Minitest::Mock.new | |
@common = Minitest::Mock.new | |
@mirrordatabase = Minitest::Mock.new | |
@watcher = Minitest::Mock.new | |
mirrorsyncdaemon = MirrorSyncDaemon.new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment