foreverb 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES.md CHANGED
@@ -1,3 +1,14 @@
1
+ # Version 0.2.6 - August 27, 2011
2
+
3
+ * Added back support for update the daemon config
4
+ * Improved a bit our outputs showing the daemon name
5
+
6
+ # Version 0.2.5 - August 26, 2011
7
+
8
+ * Moved stop to kill
9
+ * Added a new stop method that wait until workers are idle
10
+ * Improved a bit outputs
11
+
1
12
  # Version 0.2.4 - July 25, 2011
2
13
 
3
14
  * Ruby 1.9.2 compatibility
@@ -13,4 +24,4 @@
13
24
  * Added `restart` CLI command
14
25
  * Added `tail` CLI command
15
26
  * Added `update` CLI command (useful to update daemons config)
16
- * Improved documentation (aka the readme)
27
+ * Improved documentation (aka the readme)
data/Rakefile CHANGED
@@ -10,9 +10,12 @@ end
10
10
 
11
11
  desc "Bump version on github"
12
12
  task :bump do
13
- puts "\e[31mNothing to commit (working directory clean)\e[0m" and return if `git status -s`.strip == ""
14
- version = Bundler.load_gemspec(Dir[File.expand_path('../*.gemspec', __FILE__)].first).version
15
- sh "git add .; git commit -a -m \"Bump to version #{version}\""
13
+ if `git status -s`.strip == ""
14
+ puts "\e[31mNothing to commit (working directory clean)\e[0m"
15
+ else
16
+ version = Bundler.load_gemspec(Dir[File.expand_path('../*.gemspec', __FILE__)].first).version
17
+ sh "git add .; git commit -a -m \"Bump to version #{version}\""
18
+ end
16
19
  end
17
20
 
18
21
  task :release => :bump
data/bin/foreverb CHANGED
@@ -99,7 +99,7 @@ class CLI < Thor
99
99
  return if match.empty?
100
100
  FileUtils.rm_rf(FOREVER_PATH)
101
101
  match.each do |conf|
102
- system(conf[:file], 'up') if options.yes || yes?("Do you want really update config from \e[1m#{conf[:file]}\e[0m?")
102
+ system(conf[:file], 'update') if options.yes || yes?("Do you want really update config from \e[1m#{conf[:file]}\e[0m?")
103
103
  end
104
104
  end
105
105
 
data/lib/forever/base.rb CHANGED
@@ -28,9 +28,12 @@ module Forever
28
28
  when 'kill'
29
29
  stop!
30
30
  exit
31
- when 'help', '-h'
32
- print <<-RUBY.gsub(/ {10}/,'') % File.basename(file)
33
- Usage: \e[1m./%s\e[0m [start|stop|kill|restart|config]
31
+ when 'update'
32
+ print "[\e[90m%s\e[0m] Config written in \e[1m%s\e[0m\n" % [name, FOREVER_PATH]
33
+ exit
34
+ else
35
+ print <<-RUBY.gsub(/ {10}/,'') % name
36
+ Usage: \e[1m./%s\e[0m [start|stop|kill|restart|config|update]
34
37
 
35
38
  Commands:
36
39
 
@@ -39,6 +42,7 @@ module Forever
39
42
  restart same as start
40
43
  kill force stop by sending a KILL signal to the process
41
44
  config show the current daemons config
45
+ update update the daemon config
42
46
 
43
47
  RUBY
44
48
  exit
@@ -46,7 +50,7 @@ module Forever
46
50
 
47
51
  fork do
48
52
  $0 = "Forever: #{$0}"
49
- print "=> Process demonized with pid \e[1m#{Process.pid}\e[0m with Forever v.#{Forever::VERSION}\n"
53
+ print "[\e[90m%s\e[0m] Process demonized with pid \e[1m%d\e[0m with Forever v.%s\n" % [name, Process.pid, Forever::VERSION]
50
54
 
51
55
  %w(INT TERM KILL).each { |signal| trap(signal) { stop! } }
52
56
  trap(:HUP) do
@@ -94,6 +98,13 @@ module Forever
94
98
  value ? @_file = value : @_file
95
99
  end
96
100
 
101
+ ##
102
+ # Daemon name
103
+ #
104
+ def name
105
+ File.basename(file, '.*')
106
+ end
107
+
97
108
  ##
98
109
  # Base working Directory
99
110
  #
@@ -107,7 +118,7 @@ module Forever
107
118
  # Default: dir + 'log/[process_name].log'
108
119
  #
109
120
  def log(value=nil)
110
- @_log ||= File.join(dir, "log/#{File.basename(file)}.log") if exists?(dir, file)
121
+ @_log ||= File.join(dir, "log/#{name}.log") if exists?(dir, file)
111
122
  value.nil? ? @_log : @_log = value
112
123
  end
113
124
 
@@ -117,7 +128,7 @@ module Forever
117
128
  # Default: dir + 'tmp/[process_name].pid'
118
129
  #
119
130
  def pid(value=nil)
120
- @_pid ||= File.join(dir, "tmp/#{File.basename(file)}.pid") if exists?(dir, file)
131
+ @_pid ||= File.join(dir, "tmp/#{name}.pid") if exists?(dir, file)
121
132
  value.nil? ? @_pid : @_pid = value
122
133
  end
123
134
 
@@ -129,11 +140,11 @@ module Forever
129
140
  if running?
130
141
  pid_was = File.read(pid).to_i
131
142
  FileUtils.rm_f(pid)
132
- print "=> Killing process \e[1m%d\e[0m...\n" % pid_was
143
+ print "[\e[90m%s\e[0m] Killing process \e[1m%d\e[0m...\n" % [name, pid_was]
133
144
  on_exit.call if on_exit
134
145
  Process.kill(:KILL, pid_was)
135
146
  else
136
- print "=> Process with \e[1mnot found\e[0m"
147
+ print "[\e[90m%s\e[0m] Process with \e[1mnot found\e[0m" % name
137
148
  end
138
149
  end
139
150
 
@@ -142,7 +153,7 @@ module Forever
142
153
  #
143
154
  def stop
144
155
  if running?
145
- print '=> Waiting the daemon\'s death '
156
+ print "[\e[90m%s\e[0m] Waiting the daemon\'s death " % name
146
157
  FileUtils.touch(stop_txt)
147
158
  while running?(true)
148
159
  print '.'; $stdout.flush
@@ -179,9 +190,9 @@ module Forever
179
190
  def running?(silent=false)
180
191
  if exists?(pid)
181
192
  current = File.read(pid).to_i
182
- print "=> Found pid \e[1m%d\e[0m...\n" % current unless silent
193
+ print "[\e[90m%s\e[0m] Found pid \e[1m%d\e[0m...\n" % [name, current] unless silent
183
194
  else
184
- print "=> Pid \e[1mnot found\e[0m, process seems don't exist!\n" unless silent
195
+ print "[\e[90m%s\e[0m] Pid \e[1mnot found\e[0m, process seems don't exist!\n" % name unless silent
185
196
  return false
186
197
  end
187
198
 
@@ -1,3 +1,3 @@
1
1
  module Forever
2
- VERSION = "0.2.5" unless defined?(Forever::VERSION)
2
+ VERSION = "0.2.6" 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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
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: 2011-08-26 00:00:00 +02:00
18
+ date: 2011-08-27 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency