From abbae2bb339087a4dc17f73e00a36f1c6839a9d1 Mon Sep 17 00:00:00 2001 From: Dzmitry Plashchynski Date: Sun, 29 May 2022 21:18:07 +0300 Subject: [PATCH] remove deprecated --- .gitignore | 1 + Gemfile.lock | 8 ++++++++ README.md | 1 - crono.gemspec | 1 + lib/crono.rb | 1 + lib/crono/cli.rb | 18 ------------------ lib/crono/config.rb | 5 ++--- spec/cli_spec.rb | 5 ----- spec/config_spec.rb | 7 ------- spec/internal/db/crono_test.sqlite | Bin 32768 -> 32768 bytes test/lib/cli_test.rb | 5 ----- 11 files changed, 13 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index f593750..a5147fe 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /tmp/ log/*.log .byebug_history +spec/internal diff --git a/Gemfile.lock b/Gemfile.lock index e1af616..afe1819 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,7 @@ PATH specs: crono (1.1.2) rails (>= 5.2.8) + sprockets-rails GEM remote: https://rubygems.org/ @@ -179,6 +180,13 @@ GEM rack (~> 2.2) rack-protection (= 2.2.0) tilt (~> 2.0) + sprockets (4.0.3) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) sqlite3 (1.4.2) strscan (3.0.3) temple (0.8.2) diff --git a/README.md b/README.md index cdfeb1d..9ada661 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,6 @@ Usage: crono [options] [start|stop|restart|run] -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) ``` diff --git a/crono.gemspec b/crono.gemspec index a3795c2..ebcf676 100644 --- a/crono.gemspec +++ b/crono.gemspec @@ -19,6 +19,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.add_dependency 'rails', '>= 5.2.8' + s.add_dependency 'sprockets-rails' s.add_development_dependency 'rake', '>= 13.0.1' s.add_development_dependency 'bundler', '>= 2' s.add_development_dependency 'rspec', '>= 3.10' diff --git a/lib/crono.rb b/lib/crono.rb index ae4f927..be0d8e8 100644 --- a/lib/crono.rb +++ b/lib/crono.rb @@ -3,6 +3,7 @@ module Crono end require 'rails' +require 'sprockets/railtie' require 'active_support/all' require 'crono/version' require 'crono/engine' diff --git a/lib/crono/cli.rb b/lib/crono/cli.rb index 4867e63..b77f53e 100644 --- a/lib/crono/cli.rb +++ b/lib/crono/cli.rb @@ -50,25 +50,11 @@ def have_jobs? def setup_log if config.daemonize self.logfile = config.logfile - elsif config.deprecated_daemonize - self.logfile = config.logfile - deprecated_daemonize else self.logfile = STDOUT end end - def deprecated_daemonize - ::Process.daemon(true, true) - - [$stdout, $stderr].each do |io| - File.open(config.logfile, 'ab') { |f| io.reopen(f) } - io.sync = true - end - - $stdin.reopen('/dev/null') - end - def write_pid return unless config.pidfile pidfile = File.expand_path(config.pidfile) @@ -150,10 +136,6 @@ def parse_options(argv) config.process_name = process_name end - opts.on("-d", "--[no-]daemonize", "Deprecated! Instead use crono [start|stop|restart] without this option; Daemonize process (Default: #{config.daemonize})") do |daemonize| - config.deprecated_daemonize = daemonize - end - opts.on("-m", "--monitor", "Start monitor process for a deamon (Default #{config.monitor})") do config.monitor = true end diff --git a/lib/crono/config.rb b/lib/crono/config.rb index 3a693dc..f3ca66d 100644 --- a/lib/crono/config.rb +++ b/lib/crono/config.rb @@ -8,7 +8,7 @@ class Config PROCESS_NAME = 'crono' attr_accessor :cronotab, :logfile, :pidfile, :piddir, :process_name, - :monitor, :daemonize, :deprecated_daemonize, :environment + :monitor, :daemonize, :environment def initialize self.cronotab = CRONOTAB @@ -16,7 +16,6 @@ def initialize self.piddir = PIDDIR self.process_name = PROCESS_NAME self.daemonize = false - self.deprecated_daemonize = false self.monitor = false self.environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' end @@ -28,7 +27,7 @@ def pidfile=(pidfile) end def pidfile - @pidfile || (deprecated_daemonize ? PIDFILE : nil) + @pidfile end end end diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 7ce0d29..e947441 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -63,11 +63,6 @@ expect(cli.config.monitor).to be true end - it 'should set deprecated_daemonize' do - cli.send(:parse_options, ['--daemonize']) - expect(cli.config.deprecated_daemonize).to be true - end - it 'should set environment' do cli.send(:parse_options, ['--environment', 'production']) expect(cli.config.environment).to be_eql('production') diff --git a/spec/config_spec.rb b/spec/config_spec.rb index f1e4650..95d44d4 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -11,7 +11,6 @@ expect(@config.piddir).to be Crono::Config::PIDDIR expect(@config.process_name).to be Crono::Config::PROCESS_NAME expect(@config.daemonize).to be false - expect(@config.deprecated_daemonize).to be false expect(@config.monitor).to be false expect(@config.environment).to be_eql ENV['RAILS_ENV'] end @@ -25,12 +24,6 @@ specify { expect(pidfile).to be_nil } end - - context "deprecated_daemonize is true" do - before { config.deprecated_daemonize = true } - - specify { expect(pidfile).to eq Crono::Config::PIDFILE } - end end context "explicity configured" do diff --git a/spec/internal/db/crono_test.sqlite b/spec/internal/db/crono_test.sqlite index cad7ea72d08b1f45d43942b627b324184c4364ff..b00d8646c8afbecf04527e39535a946295b4d416 100644 GIT binary patch delta 119 zcmZo@U}|V!nvf(BZN$sR!@$m?&%pPDZxWvf&l}#uJo-EvyF*Ul963p zQIWB^cJfEQt;`x`nwyvLYdRPj=^B{o8d)kBT38vHTNxYa85*0I8Jigy7~zmv6kq@V D3_2Xq delta 115 zcmZo@U}|V!nvf*nJ%N{xpMjmnh=K1p-&8(vp7*@Rc#L?~Y!(#Q!M$0ZXB!iz7$dv5 zq9S8+`Q&$eTQ@J`*K{y6)HN{DH8fN(G_^7{vobZ&GdHj_Gc-0bFv20TD8K*!(qtT% diff --git a/test/lib/cli_test.rb b/test/lib/cli_test.rb index 7ce0d29..e947441 100644 --- a/test/lib/cli_test.rb +++ b/test/lib/cli_test.rb @@ -63,11 +63,6 @@ expect(cli.config.monitor).to be true end - it 'should set deprecated_daemonize' do - cli.send(:parse_options, ['--daemonize']) - expect(cli.config.deprecated_daemonize).to be true - end - it 'should set environment' do cli.send(:parse_options, ['--environment', 'production']) expect(cli.config.environment).to be_eql('production')