foreverb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -127,7 +127,7 @@ Forever.run do
127
127
  dir File.expand_path('../', __FILE__) # Default is ../../__FILE__
128
128
 
129
129
  before :all do
130
- puts "All jobs will will wait me for 1 second"; sleep 1
130
+ puts "All jobs will wait me for 1 second"; sleep 1
131
131
  end
132
132
 
133
133
  every 10.seconds, :at => "#{Time.now.hour}:00" do
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = %w(lib)
20
- s.add_dependency 'thor', '~>0.14.6'
20
+ s.add_dependency 'thor', '~>0.16.0'
21
21
  s.add_development_dependency 'minitest'
22
+ s.add_development_dependency 'rspec'
22
23
  end
@@ -6,10 +6,11 @@ module Forever
6
6
  attr_reader :started_at
7
7
 
8
8
  def initialize(options={}, &block)
9
+ @options = options
9
10
  forking = options.delete(:fork)
10
11
 
11
12
  # Run others methods
12
- options.each { |k,v| send(k, v) }
13
+ options.each { |k,v| send(k, v) if respond_to?(k) }
13
14
 
14
15
  instance_eval(&block)
15
16
 
@@ -26,6 +27,9 @@ module Forever
26
27
  exit
27
28
  when 'start', 'restart', 'up', nil
28
29
  stop
30
+ when 'run'
31
+ detach = false
32
+ stop
29
33
  when 'stop'
30
34
  stop
31
35
  exit
@@ -62,12 +66,12 @@ module Forever
62
66
  # Enable REE - http://www.rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
63
67
  GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
64
68
 
65
- fork do
66
- Process.setsid
69
+ maybe_fork(detach) do
70
+ Process.setsid if detach != false
67
71
 
68
- $0 = "Forever: #{$0}"
69
- print "[\e[90m%s\e[0m] Process demonized with pid \e[1m%d\e[0m with \e[1m%s\e[0m and Forever v.%s\n" %
70
- [name, Process.pid, forking ? :fork : :thread, Forever::VERSION]
72
+ $0 = "Forever: #{$0}" unless ENV['DONT_TOUCH_PS']
73
+ print "[\e[90m%s\e[0m] Process %s with pid \e[1m%d\e[0m with \e[1m%s\e[0m and Forever v.%s\n" %
74
+ [name, detach != false ? :daemonized : :running, Process.pid, forking ? :fork : :thread, Forever::VERSION]
71
75
 
72
76
  %w(INT TERM KILL).each { |signal| trap(signal) { stop! } }
73
77
  trap(:HUP) do
@@ -76,7 +80,7 @@ module Forever
76
80
 
77
81
  File.open(pid, "w") { |f| f.write(Process.pid.to_s) } if pid
78
82
 
79
- stream = log ? File.new(log, "w") : File.open('/dev/null', 'w')
83
+ stream = log ? File.new(log, @options[:append_log] ? 'a' : 'w') : File.open('/dev/null', 'w')
80
84
  stream.sync = true
81
85
 
82
86
  STDOUT.reopen(stream)
@@ -340,6 +344,14 @@ module Forever
340
344
  File.exist?(stop_txt) && File.mtime(stop_txt) > started_at
341
345
  end
342
346
 
347
+ def maybe_fork(detach,&block)
348
+ if detach != false
349
+ fork &block
350
+ else
351
+ yield
352
+ end
353
+ end
354
+
343
355
  def write_config!
344
356
  config_was = File.exist?(FOREVER_PATH) ? YAML.load_file(FOREVER_PATH) : []
345
357
  config_was.delete_if { |conf| conf.nil? || conf.empty? || conf[:file] == file }
@@ -1,3 +1,3 @@
1
1
  module Forever
2
- VERSION = "0.3.0" unless defined?(Forever::VERSION)
2
+ VERSION = "0.3.1" unless defined?(Forever::VERSION)
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreverb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - DAddYE
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-25 00:00:00 Z
18
+ date: 2012-09-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: thor
@@ -25,12 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 43
28
+ hash: 95
29
29
  segments:
30
30
  - 0
31
- - 14
32
- - 6
33
- version: 0.14.6
31
+ - 16
32
+ - 0
33
+ version: 0.16.0
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,20 @@ dependencies:
47
47
  version: "0"
48
48
  type: :development
49
49
  version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :development
63
+ version_requirements: *id003
50
64
  description: Small daemon framework for ruby, with logging, error handler, scheduling and much more.
51
65
  email:
52
66
  - d.dagostino@lipsiasoft.com
@@ -104,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
118
  requirements: []
105
119
 
106
120
  rubyforge_project: foreverb
107
- rubygems_version: 1.8.15
121
+ rubygems_version: 1.8.24
108
122
  signing_key:
109
123
  specification_version: 3
110
124
  summary: Small daemon framework for ruby