Sha256: 70190194760cff893516ab30fa744dc0f95f6c04f3bbb0439f5d52b19996319b
Contents?: true
Size: 966 Bytes
Versions: 113
Compression:
Stored size: 966 Bytes
Contents
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../lib')) if File.exist?(File.join(lib_dir, 'daemons.rb')) $LOAD_PATH.unshift lib_dir else begin; require 'rubygems'; rescue ::Exception; end end require 'daemons' require 'optparse' require 'logger' require 'ostruct' class MyApp < Logger::Application def initialize(args) super(self.class) @options = OpenStruct.new(:daemonize => true) opts = OptionParser.new do |opts| opts.banner = 'Usage: myapp [options]' opts.separator '' opts.on('-N','--no-daemonize',"Don't run as a daemon") do @options.daemonize = false end end @args = opts.parse!(args) end def run Daemons.run_proc('myapp',{:ARGV => @args, :ontop => !@options.daemonize}) do puts "@options.daemonize: #{@options.daemonize}" STDOUT.sync = true loop do print '.' sleep(2) end end end end myapp = MyApp.new(ARGV) myapp.run
Version data entries
113 entries across 113 versions & 13 rubygems