From 16ca450033c8a6a41912f7fcd7e09e008b94bf0e Mon Sep 17 00:00:00 2001 From: Dzmitry Plashchynski Date: Wed, 20 Jan 2016 20:41:26 +0200 Subject: [PATCH] Fix option parser --- Gemfile.lock | 2 +- README.md | 27 +++++++++++++++++++++------ lib/crono/cli.rb | 4 ++-- lib/crono/version.rb | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cd43855..52c4cf2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - crono (1.0.0.pre2) + crono (1.0.0.pre3) activerecord (~> 4.0) activesupport (~> 4.0) diff --git a/README.md b/README.md index 9e3cb38..45ec41a 100644 --- a/README.md +++ b/README.md @@ -131,23 +131,38 @@ serialized using JSON.generate Crono.perform(TestJob, 'some', 'args').every 1.day, at: {hour: 12, min: 15} ``` -#### Run daemon +#### Run -To run Crono daemon, in your Rails project root directory: +To run Crono, in your Rails project root directory: bundle exec crono RAILS_ENV=development crono usage: ``` -Usage: crono [options] start|stop|restart|run +Usage: crono [options] [start|stop|restart|run] -C, --cronotab PATH Path to cronotab file (Default: config/cronotab.rb) -L, --logfile PATH Path to writable logfile (Default: log/crono.log) - --piddir PATH Path to piddir (Default: tmp/pids) - -N, --process_name name Name of the process (Default: crono) + -P, --pidfile PATH Deprecated! use --piddir with --process_name; Path to pidfile (Default: ) + -D, --piddir PATH Path to piddir (Default: tmp/pids) + -N, --process_name NAME Name of the process (Default: crono) + -d, --[no-]daemonize Deprecated! Instead use crono [start|stop|restart] without this option; Daemonize process (Default: false) -m, --monitor Start monitor process for a deamon (Default false) - -e, --environment ENV Application environment (Default: development) + -e, --environment ENV Application environment (Default: development) ``` +#### Run as daemon + +To run Crono as daemon, please add to your Gemfile: + +```ruby +gem 'daemons' +``` + +Then: + + bundle install; bundle exec crono start RAILS_ENV=development + +There are "start", "stop", and "restart" commands. ## Web UI diff --git a/lib/crono/cli.rb b/lib/crono/cli.rb index b391a86..5bf55b3 100644 --- a/lib/crono/cli.rb +++ b/lib/crono/cli.rb @@ -122,7 +122,7 @@ module Crono def parse_options(argv) @argv = OptionParser.new do |opts| - opts.banner = "Usage: crono [options] start|stop|restart|run" + opts.banner = "Usage: crono [options] [start|stop|restart|run]" opts.on("-C", "--cronotab PATH", "Path to cronotab file (Default: #{config.cronotab})") do |cronotab| config.cronotab = cronotab @@ -136,7 +136,7 @@ module Crono config.pidfile = pidfile end - opts.on("--piddir PATH", "Path to piddir (Default: #{config.piddir})") do |piddir| + opts.on("-D", "--piddir PATH", "Path to piddir (Default: #{config.piddir})") do |piddir| config.piddir = piddir end diff --git a/lib/crono/version.rb b/lib/crono/version.rb index 626f33d..ff9fef5 100644 --- a/lib/crono/version.rb +++ b/lib/crono/version.rb @@ -1,3 +1,3 @@ module Crono - VERSION = '1.0.0.pre2' + VERSION = '1.0.0.pre3' end