Sha256: e960e0a49759a26475e98a4d94470b600537d6737711b7cd99d60e894e23dc0c

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

module Splash
  module LogsMonitor
    module DaemonController
      include Splash::Constants
      include Splash::Helpers
      include Splash::Config

      def startdaemon(options = {})
        config = get_config
        unless File::exist? config.full_pid_path then
          return daemonize :description => config.daemon_process_name,
                           :pid_file => config.full_pid_path,
                           :daemon_user => config.daemon_user,
                           :daemon_group => config.daemon_group,
                           :stdout_trace => config.full_stdout_trace_path,
                           :stderr_trace => config.full_stderr_trace_path do
            result = LogScanner::new
            while true
              sleep 5
              puts "Notify"
              result.analyse
              result.notify
            end
          end
        end
      end

      def stopdaemon(options = {})
          config = get_config
          if File.exist?(config.full_pid_path) then

            begin
              pid = `cat #{config.full_pid_path}`.to_i
              Process.kill("TERM", pid)
            rescue Errno::ESRCH
              $stderr.puts "Process of PID : #{pid} not found"
            end
              FileUtils::rm config.full_pid_path if File::exist? config.full_pid_path
            return true
          else
            return false
          end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prometheus-splash-0.0.1 lib/splash/controller.rb