Class: Vidibus::Recording::Daemon
- Inherits:
-
Object
- Object
- Vidibus::Recording::Daemon
- Defined in:
- lib/vidibus/recording/daemon.rb
Instance Method Summary collapse
- #daemonize ⇒ Object
-
#initialize(args) ⇒ Daemon
constructor
A new instance of Daemon.
- #run ⇒ Object
- #run_process(name, dir) ⇒ Object
Constructor Details
#initialize(args) ⇒ Daemon
Returns a new instance of Daemon.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vidibus/recording/daemon.rb', line 12 def initialize(args) @options = {:pid_dir => "#{Rails.root}/tmp/pids"} = OptionParser.new do || . = "Usage: #{File.basename($0)} start|stop|restart" .on('-h', '--help', 'Show this message') do puts exit 1 end end @args = .parse!(args) end |
Instance Method Details
#daemonize ⇒ Object
24 25 26 27 28 |
# File 'lib/vidibus/recording/daemon.rb', line 24 def daemonize dir = @options[:pid_dir] Dir.mkdir(dir) unless File.exists?(dir) run_process('recording', dir) end |
#run ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vidibus/recording/daemon.rb', line 34 def run Dir.chdir(Rails.root) log = File.join(Rails.root, 'log', 'recording.log') Vidibus::Recording.logger = ActiveSupport::BufferedLogger.new(log) Vidibus::Recording.monitor rescue => e Vidibus::Recording.logger.fatal(e) STDERR.puts(e.) exit 1 end |
#run_process(name, dir) ⇒ Object
30 31 32 |
# File 'lib/vidibus/recording/daemon.rb', line 30 def run_process(name, dir) Daemons.run_proc(name, :dir => dir, :dir_mode => :normal) { run } end |