Skip to content

Commit

Permalink
remove deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
plashchynski committed May 29, 2022
1 parent 5831e04 commit abbae2b
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/tmp/
log/*.log
.byebug_history
spec/internal
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
crono (1.1.2)
rails (>= 5.2.8)
sprockets-rails

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down
1 change: 1 addition & 0 deletions crono.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions lib/crono.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Crono
end

require 'rails'
require 'sprockets/railtie'
require 'active_support/all'
require 'crono/version'
require 'crono/engine'
Expand Down
18 changes: 0 additions & 18 deletions lib/crono/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions lib/crono/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ 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
self.logfile = LOGFILE
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
Expand All @@ -28,7 +27,7 @@ def pidfile=(pidfile)
end

def pidfile
@pidfile || (deprecated_daemonize ? PIDFILE : nil)
@pidfile
end
end
end
5 changes: 0 additions & 5 deletions spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
7 changes: 0 additions & 7 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Binary file modified spec/internal/db/crono_test.sqlite
Binary file not shown.
5 changes: 0 additions & 5 deletions test/lib/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit abbae2b

Please sign in to comment.