mlanett-daemons 1.0.13 → 1.1.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/Gemfile.lock +12 -2
  2. data/LICENSE +1 -8
  3. data/README-mlanett.rdoc +8 -0
  4. data/{README → README.rdoc} +6 -15
  5. data/Releases +84 -9
  6. data/TODO +1 -5
  7. data/daemons.gemspec +1 -0
  8. data/examples/call/call.rb +1 -0
  9. data/examples/daemonize/daemonize.rb +10 -3
  10. data/examples/run/ctrl_hanging.rb +19 -0
  11. data/examples/run/ctrl_monitor_multiple.rb +18 -0
  12. data/examples/run/ctrl_normal.rb +0 -1
  13. data/examples/run/ctrl_proc.rb.output +20 -0
  14. data/examples/run/ctrl_proc_rand.rb +23 -0
  15. data/examples/run/ctrl_slowstop.rb +16 -0
  16. data/examples/run/myserver_crashing.rb +2 -2
  17. data/examples/run/myserver_hanging.rb +21 -0
  18. data/examples/run/myserver_slowstop.rb +21 -0
  19. data/lib/daemons.rb +38 -10
  20. data/lib/daemons/application.rb +131 -26
  21. data/lib/daemons/application_group.rb +58 -10
  22. data/lib/daemons/change_privilege.rb +19 -0
  23. data/lib/daemons/cmdline.rb +10 -6
  24. data/lib/daemons/controller.rb +5 -2
  25. data/lib/daemons/daemonize.rb +64 -150
  26. data/lib/daemons/etc_extension.rb +12 -0
  27. data/lib/daemons/exceptions.rb +3 -0
  28. data/lib/daemons/monitor.rb +27 -19
  29. data/lib/daemons/pid.rb +13 -14
  30. data/lib/daemons/pidfile.rb +14 -7
  31. data/lib/daemons/pidmem.rb +9 -0
  32. data/lib/daemons/version.rb +1 -1
  33. data/spec/pidfile_spec.rb +12 -0
  34. data/spec/spec_helper.rb +1 -0
  35. metadata +31 -47
  36. data/daemons.tmproj +0 -56
  37. data/examples/run/myserver_crashing.rb.output +0 -30
  38. data/html/classes/Daemonize.html +0 -497
  39. data/html/classes/Daemons.html +0 -683
  40. data/html/classes/Daemons/Application.html +0 -836
  41. data/html/classes/Daemons/ApplicationGroup.html +0 -508
  42. data/html/classes/Daemons/CmdException.html +0 -113
  43. data/html/classes/Daemons/Controller.html +0 -429
  44. data/html/classes/Daemons/Error.html +0 -113
  45. data/html/classes/Daemons/Exception.html +0 -111
  46. data/html/classes/Daemons/Monitor.html +0 -263
  47. data/html/classes/Daemons/Optparse.html +0 -244
  48. data/html/classes/Daemons/Pid.html +0 -339
  49. data/html/classes/Daemons/PidFile.html +0 -441
  50. data/html/classes/Daemons/PidMem.html +0 -126
  51. data/html/classes/Daemons/RuntimeException.html +0 -113
  52. data/html/classes/Daemons/SystemError.html +0 -163
  53. data/html/created.rid +0 -1
  54. data/html/files/README.html +0 -377
  55. data/html/files/Releases.html +0 -342
  56. data/html/files/TODO.html +0 -121
  57. data/html/files/lib/daemons/application_group_rb.html +0 -101
  58. data/html/files/lib/daemons/application_rb.html +0 -110
  59. data/html/files/lib/daemons/cmdline_rb.html +0 -101
  60. data/html/files/lib/daemons/controller_rb.html +0 -101
  61. data/html/files/lib/daemons/daemonize_rb.html +0 -207
  62. data/html/files/lib/daemons/exceptions_rb.html +0 -101
  63. data/html/files/lib/daemons/monitor_rb.html +0 -108
  64. data/html/files/lib/daemons/pid_rb.html +0 -108
  65. data/html/files/lib/daemons/pidfile_rb.html +0 -108
  66. data/html/files/lib/daemons/pidmem_rb.html +0 -108
  67. data/html/files/lib/daemons_rb.html +0 -117
  68. data/html/fr_class_index.html +0 -41
  69. data/html/fr_file_index.html +0 -40
  70. data/html/fr_method_index.html +0 -91
  71. data/html/index.html +0 -24
  72. data/html/rdoc-style.css +0 -208
  73. data/test/call_as_daemon.rb +0 -12
  74. data/test/tc_main.rb +0 -24
  75. data/test/test1.rb +0 -19
  76. data/test/testapp.rb +0 -11
data/Gemfile.lock CHANGED
@@ -1,17 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- daemons (1.0.13)
4
+ mlanett-daemons (1.1.10.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ diff-lcs (1.2.4)
9
10
  rake (10.1.0)
11
+ rspec (2.14.1)
12
+ rspec-core (~> 2.14.0)
13
+ rspec-expectations (~> 2.14.0)
14
+ rspec-mocks (~> 2.14.0)
15
+ rspec-core (2.14.5)
16
+ rspec-expectations (2.14.3)
17
+ diff-lcs (>= 1.1.3, < 2.0)
18
+ rspec-mocks (2.14.3)
10
19
 
11
20
  PLATFORMS
12
21
  ruby
13
22
 
14
23
  DEPENDENCIES
15
24
  bundler (>= 1.0)
16
- daemons!
25
+ mlanett-daemons!
17
26
  rake
27
+ rspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005-2007 Thomas Uehlinger
1
+ Copyright (c) 2005-2012 Thomas Uehlinger
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
@@ -20,10 +20,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
20
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
21
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
22
  OTHER DEALINGS IN THE SOFTWARE.
23
-
24
- This license does not apply to daemonize.rb, which is was written by
25
- Travis Whitton und published under the following license:
26
-
27
- The Daemonize extension module is copywrited free software by Travis Whitton
28
- <whitton@atlantic.net>. You can redistribute it under the terms specified in
29
- the COPYING file of the Ruby distribution.
@@ -0,0 +1,8 @@
1
+ == What is Daemons?
2
+
3
+ This is a fork of the original svn upstream by Thomas Uehlinger.
4
+
5
+ It incorporates some bug fixes from myself and some other git repos,
6
+ which are forked from an older version of the upstream.
7
+
8
+ This gem is pushed to rubygems as mlanett-daemons.
@@ -1,4 +1,4 @@
1
- = Daemons Version 1.0.11
1
+ = Daemons Version 1.1.10
2
2
 
3
3
  (See Releases for release-specific information)
4
4
 
@@ -14,12 +14,9 @@ Besides this basic functionality, daemons offers many advanced features like <i>
14
14
  and logging (in case your ruby script crashes) and <i>monitoring</i> and automatic restarting of your processes
15
15
  if they crash.
16
16
 
17
- Daemons includes the <tt>daemonize.rb</tt> script written by <i>Travis Whitton</i> to do the daemonization
18
- process.
19
-
20
17
  == Basic Usage
21
18
 
22
- You can use Daemons in four differet ways:
19
+ You can use Daemons in four different ways:
23
20
 
24
21
  === 1. Create wrapper scripts for your server scripts or applications
25
22
 
@@ -184,11 +181,12 @@ The RDoc documentation is also online at http://daemons.rubyforge.org
184
181
 
185
182
  == Author
186
183
 
187
- Written in 2005-2008 by Thomas Uehlinger <mailto:th.uehlinger@gmx.ch>.
184
+ Written 2005-2013 by Thomas Uehlinger <mailto:th.uehlinger@gmx.ch>.
185
+ Anonymous SVN checkout is available with "svn checkout http://daemons.rubyforge.org/svn/".
188
186
 
189
187
  == License
190
188
 
191
- Copyright (c) 2005-2008 Thomas Uehlinger
189
+ Copyright (c) 2005-2013 Thomas Uehlinger
192
190
 
193
191
  Permission is hereby granted, free of charge, to any person
194
192
  obtaining a copy of this software and associated documentation
@@ -211,13 +209,6 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
211
209
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
212
210
  OTHER DEALINGS IN THE SOFTWARE.
213
211
 
214
- This license does not apply to daemonize.rb, which is was written by
215
- Travis Whitton und published under the following license:
216
-
217
- The Daemonize extension module is copywrited free software by Travis Whitton
218
- <whitton@atlantic.net>. You can redistribute it under the terms specified in
219
- the COPYING file of the Ruby distribution.
220
-
221
212
  == Feedback and other resources
222
213
 
223
- At http://rubyforge.org/projects/daemons.
214
+ At http://rubyforge.org/projects/daemons .
data/Releases CHANGED
@@ -1,26 +1,100 @@
1
1
  = Daemons Release History
2
2
 
3
- == Release 1.0.10: November 16, 2007
3
+ == Release 1.1.10: June 26, 2013
4
+
5
+ * fix Pid.running? rescuing timeout exceptions (thanks to Geraud Boyer)
6
+ * monitor.rb/application.rb/application_group.rb: handle :monitor and :multiple in combination correctly
7
+ (thanks to Prakash Murthy).
8
+
9
+ == Release 1.1.9: August 10, 2012
10
+
11
+ * daemonize.rb: do srand in the forked child process both in daemonize and call_as_daemon
12
+ (thanks to Andrew Havens).
13
+
14
+ == Release 1.1.8: February 7, 2012
15
+
16
+ * rename to daemonization.rb to daemonize.rb (and Daemonization to Daemonize) to
17
+ ensure compatibility.
18
+
19
+ == Release 1.1.7: February 6, 2012
20
+
21
+ * start_proc: Write out the PID file in the newly created proc to avoid race conditions.
22
+ * daemonize.rb: remove to simplify licensing (replaced by daemonization.rb).
23
+
24
+ == Release 1.1.6: January 18, 2012
25
+
26
+ * Add the :app_name option for the "call" daemonization mode.
27
+
28
+ == Release 1.1.5: December 19, 2011
29
+
30
+ * Catch the case where the pidfile is empty but not deleted
31
+ and restart the app (thanks to Rich Healey)
32
+
33
+ == Release 1.1.4: June 17, 2011
34
+
35
+ * Do not change the umask to 0000 when daemonizing anymore, just leave it as it
36
+ was (thanks to Jon Botelho).
37
+
38
+ == Release 1.1.3: April 14, 2011
39
+
40
+ * Fixed a bug in Application.stop: the cached pid number needs to
41
+ be used to check for the status of a killed process (thanks to Jimmy Sieben).
42
+
43
+ == Release 1.1.2: March 29, 2011
44
+
45
+ * Fixed gemspec to include all needed files.
46
+
47
+ == Release 1.1.1: March 29, 2011
48
+
49
+ * Make the logging facilities work in :mode => :none (i.e. when calling
50
+ Daemons.daemonize) (thanks to the input from Peter Hegedus).
51
+
52
+ == Release 1.1.0: June 20, 2010
53
+
54
+ * Honour the options[:app_name] in Daemons.daemonize (thanks to Ryan Tecco).
55
+ * Included a new option :stop_proc to specify a proc that will be called when a
56
+ daemonized process receives a request to stop (thanks to Dave Dupre).
57
+ * Only delete the pidfile if the current pid is the original pid (ghazel).
58
+ * Start when restart but no application running (pcreux).
59
+ * Silently continue if there is no pidfile (ghazel).
60
+ * We now per default wait for processes to stop and
61
+ kill them automatically it if they do not stop within a given time
62
+ (force_kill_waittime). Use the option --no_wait to not wait for processes to
63
+ stop.
64
+ * Set log files mode to 0644 (mikehale).
65
+ * Set pid file permissions to 0644 (mikehale).
66
+ * Added ability to change process uid/gid (mikehale).
67
+ * Fix for: If you happen to start a daemon from a process that has open file
68
+ descriptors these will stay open. As it is daemonize.rb only closes ruby IO
69
+ objects (thanks to Han Holl).
70
+ * New reload command (SIGHUP) (thanks to Michael Schuerig).
71
+
72
+ == Release 1.0.10: March 21, 2008
4
73
 
5
74
  * By default, we now delete stray pid-files (i.e. pid-files which result for
6
- example from a killed daemon) automatically. This function can be deactivated by
7
- passing :keep_pid_files => true as an option.
8
- * All pid files of :multiple daemons new get deleted correctly upon exit of the daemons (reported by Han Holl).
75
+ example from a killed daemon) automatically. This function can be deactivated
76
+ by passing :keep_pid_files => true as an option.
77
+ * All pid files of :multiple daemons new get deleted correctly upon exit of the
78
+ daemons (reported by Han Holl).
9
79
  * Use the signal 'KILL' instead of 'TERM' on Windows platforms.
10
- * Use exit! in trap('TERM') instead of exit when option :hard_exit is given (thanks to Han Holl).
80
+ * Use exit! in trap('TERM') instead of exit when option :hard_exit is given
81
+ (thanks to Han Holl).
11
82
  * Did some clarification on the exception log.
12
83
 
13
84
  == Release 1.0.9: October 29, 2007
14
85
 
15
- * fixed a severe bug in the new Pid.running? function: function returned true if the process did not exist (thanks to Jeremy Lawler).
86
+ * fixed a severe bug in the new Pid.running? function: function returned true if
87
+ the process did not exist (thanks to Jeremy Lawler).
16
88
 
17
89
  == Release 1.0.8: September 24, 2007
18
90
 
19
- * new Pid.running? function. Checking whether a process exists by sending signal '0' (thanks to Dru Nelson).
91
+ * new Pid.running? function. Checking whether a process exists by sending
92
+ signal '0' (thanks to Dru Nelson).
20
93
 
21
94
  == Release 1.0.7: July 7, 2007
22
95
 
23
- * Patch to fix wrong ARGV when using :exec (in def start_exec: Kernel.exec(script(), *(@app_argv || []))) (thanks to Alex McGuire).
96
+ * Patch to fix wrong ARGV when using :exec (in def start_exec:
97
+ Kernel.exec(script(), *(@app_argv || []))) (thanks to Alex McGuire).
24
98
 
25
99
  == Release 1.0.6: Mai 8, 2007
26
100
 
@@ -37,7 +111,8 @@
37
111
 
38
112
  * Document the :log_output option (thanks to Andrew Kuklewicz).
39
113
  * Set STDOUT.sync = true when redirecting to a logfile (thanks to Andrew Kuklewicz).
40
- * Should now run also correctly when there is no working 'ps ax' on the system (thanks to Daniel Kehoe).
114
+ * Should now run also correctly when there is no working 'ps ax' on the system
115
+ (thanks to Daniel Kehoe).
41
116
 
42
117
  == Release 1.0.3: November 1, 2006
43
118
 
data/TODO CHANGED
@@ -1,6 +1,2 @@
1
- * write the README (2005-02-07) *DONE*
2
- * write some real tests (2005-02-08)
3
- * document the new options (2005-03-14) *DONE*
4
- * start/stop with --force options (2005-04-05)
5
- * option to give some console output on start/stop commands (2005-04-05)
1
+ * put TODOS here
6
2
 
data/daemons.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency "bundler", ">= 1.0"
26
26
  spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
27
28
  end
@@ -18,6 +18,7 @@ testfile = File.expand_path(__FILE__) + '.log'
18
18
  #
19
19
 
20
20
  options = {
21
+ :app_name => 'mytask',
21
22
  # :ontop => true,
22
23
  :multiple => true
23
24
  }
@@ -11,10 +11,17 @@ end
11
11
  require 'daemons'
12
12
 
13
13
 
14
- testfile = File.expand_path(__FILE__) + '.log'
14
+ options = {
15
+ :log_output => true
16
+ }
15
17
 
16
- Daemons.daemonize
18
+
19
+ testfile = File.expand_path(__FILE__) + '.txt'
20
+
21
+ Daemons.daemonize(options)
22
+
23
+ puts "some output..."
17
24
 
18
25
  File.open(testfile, 'w') {|f|
19
26
  f.write("test")
20
- }
27
+ }
@@ -0,0 +1,19 @@
1
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
2
+
3
+ if File.exist?(File.join(lib_dir, 'daemons.rb'))
4
+ $LOAD_PATH.unshift lib_dir
5
+ else
6
+ begin; require 'rubygems'; rescue ::Exception; end
7
+ end
8
+
9
+ require 'daemons'
10
+
11
+ options = {
12
+ #:mode => :exec,
13
+ :multiple => true,
14
+ :no_pidfiles => true,
15
+ :force_kill_waittime => 5
16
+ #:force_kill_waittime => -1 # do not wait before killing -9
17
+ }
18
+
19
+ Daemons.run(File.join(File.dirname(__FILE__), 'myserver_hanging.rb'), options)
@@ -0,0 +1,18 @@
1
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
2
+
3
+ if File.exist?(File.join(lib_dir, 'daemons.rb'))
4
+ $LOAD_PATH.unshift lib_dir
5
+ else
6
+ begin; require 'rubygems'; rescue ::Exception; end
7
+ end
8
+
9
+ require 'daemons'
10
+
11
+
12
+ options = {
13
+ :multiple => true,
14
+ :monitor => true,
15
+ :log_output => true,
16
+ }
17
+
18
+ Daemons.run(File.join(File.dirname(__FILE__), 'myserver_crashing.rb'), options)
@@ -8,5 +8,4 @@ end
8
8
 
9
9
  require 'daemons'
10
10
 
11
-
12
11
  Daemons.run(File.join(File.dirname(__FILE__), 'myserver.rb'))
@@ -99,3 +99,23 @@ ping from proc!
99
99
  ping from proc!
100
100
  ping from proc!
101
101
  ping from proc!
102
+ ping from proc!
103
+ ping from proc!
104
+ ping from proc!
105
+ ping from proc!
106
+ ping from proc!
107
+ ping from proc!
108
+ ping from proc!
109
+ ctrl_proc.rb: process with pid 3187 started.
110
+ ping from proc!
111
+ ping from proc!
112
+ ping from proc!
113
+ ctrl_proc.rb: process with pid 1659 started.
114
+ ping from proc!
115
+ ping from proc!
116
+ ctrl_proc.rb: process with pid 17561 started.
117
+ ping from proc!
118
+ ping from proc!
119
+ ctrl_proc.rb: process with pid 18362 started.
120
+ ping from proc!
121
+ ping from proc!
@@ -0,0 +1,23 @@
1
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
2
+
3
+ if File.exist?(File.join(lib_dir, 'daemons.rb'))
4
+ $LOAD_PATH.unshift lib_dir
5
+ else
6
+ begin; require 'rubygems'; rescue ::Exception; end
7
+ end
8
+
9
+
10
+ require 'daemons'
11
+
12
+
13
+ Daemons.run_proc('myscript') do
14
+ loop do
15
+ file = File.open('/tmp/myscript.log', 'a')
16
+ file.write(Random.rand) # breaks without seeding
17
+ # file.write(Random.new.rand) # works without seeding
18
+ # file.write(rand) # also works, but this is Kernel.rand() so its different
19
+ file.write("\n")
20
+ file.close()
21
+ sleep 2
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
2
+
3
+ if File.exist?(File.join(lib_dir, 'daemons.rb'))
4
+ $LOAD_PATH.unshift lib_dir
5
+ else
6
+ begin; require 'rubygems'; rescue ::Exception; end
7
+ end
8
+
9
+ require 'daemons'
10
+
11
+ options = {
12
+ #:force_kill_waittime => 40
13
+ #:force_kill_waittime => -1 # do not wait before killing -9
14
+ }
15
+
16
+ Daemons.run(File.join(File.dirname(__FILE__), 'myserver_slowstop.rb'), options)
@@ -5,9 +5,9 @@
5
5
 
6
6
  loop do
7
7
  puts 'ping from myserver.rb!'
8
- puts 'this example server will crash in 3 seconds...'
8
+ puts 'this example server will crash in 10 seconds...'
9
9
 
10
- sleep(3)
10
+ sleep(10)
11
11
 
12
12
  puts 'CRASH!'
13
13
  raise 'CRASH!'
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ # This is myserver.rb, an example server that is to be controlled by daemons
5
+ # and that does nothing really useful at the moment.
6
+ #
7
+ # Don't run this script by yourself, it can be controlled by the ctrl*.rb scripts.
8
+
9
+ trap('TERM') {
10
+ puts "received TERM"
11
+
12
+ loop do
13
+ puts 'hanging!'
14
+ sleep(3)
15
+ end
16
+ }
17
+
18
+ loop do
19
+ puts 'ping from myserver.rb!'
20
+ sleep(3)
21
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ # This is myserver_slowstop.rb, an example server that is to be controlled by daemons
5
+ # and that does nothing really useful at the moment.
6
+ #
7
+ # Don't run this script by yourself, it can be controlled by the ctrl*.rb scripts.
8
+
9
+ trap('TERM') {
10
+ puts "received TERM"
11
+
12
+ # simulate the slow stopping
13
+ sleep(10)
14
+
15
+ exit
16
+ }
17
+
18
+ loop do
19
+ puts 'ping from myserver.rb!'
20
+ sleep(3)
21
+ end