Module: Forker::CLI
- Defined in:
- lib/forker.rb
Class Method Summary collapse
-
.run(argv) ⇒ Object
You can use this if your daemon is simple enough or write your own and use Forker#fork! directly.
Class Method Details
.run(argv) ⇒ Object
You can use this if your daemon is simple enough or write your own and use Forker#fork! directly
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/forker.rb', line 22 def self.run(argv) require 'optparse' = {} opts = OptionParser.new do |opts| opts. = "Usage: #{File.basename($0)} [start|stop] -p /path/to/pidfile.pid" opts.on("-l", "--logfile LOGFILE", "redirect output to this location") do |logfile| [:log] = logfile end opts.on("-p", "--pidfile PIDFILE", "save pidfile to this location") do |pidfile| [:pid] = pidfile end end opts.parse!(argv) if [:pid].nil? puts opts exit end case argv.first when "start" Forker.fork!() when "stop" Forker.kill() exit else puts opts exit end end |