From 2ce9db45dbd396234ddee260640d0d391ce30d11 Mon Sep 17 00:00:00 2001 From: Dzmitry Plashchynski Date: Tue, 3 Mar 2015 19:13:17 +0200 Subject: [PATCH] Add option to daemonize --- lib/crono/cli.rb | 5 +++++ lib/crono/config.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/crono/cli.rb b/lib/crono/cli.rb index 1e35d38..9d34927 100644 --- a/lib/crono/cli.rb +++ b/lib/crono/cli.rb @@ -49,6 +49,11 @@ module Crono opts.on("-L", "--logfile PATH", "Path to writable logfile (Default: #{Crono.config.logfile})") do |logfile| Crono.config.logfile = logfile end + + opts.on("-d", "--[no-]daemonize", "Daemonize process (Default: #{Crono.config.daemonize})") do |daemonize| + Crono.config.daemonize = daemonize + end + end.parse!(argv) end end diff --git a/lib/crono/config.rb b/lib/crono/config.rb index 76564b4..40faec3 100644 --- a/lib/crono/config.rb +++ b/lib/crono/config.rb @@ -7,11 +7,13 @@ module Crono attr_accessor :schedule attr_accessor :cronotab attr_accessor :logfile + attr_accessor :daemonize def initialize self.schedule = Schedule.new self.cronotab = CRONOTAB self.logfile = LOGFILE + self.daemonize = false end end