class Object

Public Instance Methods

run_server() { || ... } click to toggle source

Goes into the background, chdir's to /tmp, and redirect all input/output to null Beginning Ruby p. 489-490

# File flashpolicyd.rb, line 376
def run_server
  if @daemonize
    fork do
      Process.setsid
      exit if fork
      Dir.chdir('/tmp')
      STDIN.reopen('/dev/null')
      STDOUT.reopen('/dev/null', 'a')
      STDERR.reopen('/dev/null', 'a')

      trap("TERM") {
        @logger.debug("Caught TERM signal")
        exit
      }
      yield
    end
  else
    yield
  end
end
sec2dhms(secs) click to toggle source

Returns an array of days, hrs, mins and seconds given a second figure The Ruby Way - Page 227

# File flashpolicyd.rb, line 399
def sec2dhms(secs)
  time = secs.round
  sec = time % 60
  time /= 60

  mins = time % 60
  time /= 60

  hrs = time % 24
  time /= 24

  days = time
  [days, hrs, mins, sec]
end
showhelp() click to toggle source
# File check_flashpolicyd.rb, line 40
def showhelp
        begin
                puts("--host SERVER\n--port PORT\n--timeout TIMEOUT\n");
                require 'rdoc/ri/ri_paths'
                require 'rdoc/usage'
                RDoc::usage
        rescue Exception => e
                puts("Install RDoc::usage or view the comments in the top of the script to get detailed help")
        end
end