daemons 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005-2007 Thomas Uehlinger
1
+ Copyright (c) 2005-2011 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
@@ -26,4 +26,4 @@ Travis Whitton und published under the following license:
26
26
 
27
27
  The Daemonize extension module is copywrited free software by Travis Whitton
28
28
  <whitton@atlantic.net>. You can redistribute it under the terms specified in
29
- the COPYING file of the Ruby distribution.
29
+ the COPYING file of the Ruby distribution.
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = Daemons Version 1.1.0
1
+ = Daemons Version 1.1.2
2
2
 
3
3
  (See Releases for release-specific information)
4
4
 
data/Releases CHANGED
@@ -1,5 +1,14 @@
1
1
  = Daemons Release History
2
2
 
3
+ == Release 1.1.2: March 29, 201
4
+
5
+ * Fixed gemspec to include all needed files.
6
+
7
+ == Release 1.1.1: March 29, 201
8
+
9
+ * Make the logging facilities work in :mode => :none (i.e. when calling
10
+ Daemons.daemonize) (thanks to the input from Peter Hegedus).
11
+
3
12
  == Release 1.1.0: June 20, 2010
4
13
 
5
14
  * Honour the options[:app_name] in Daemons.daemonize (thanks to Ryan Tecco).
@@ -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
+ }
data/lib/daemons.rb CHANGED
@@ -66,7 +66,7 @@ require 'timeout'
66
66
  #
67
67
  module Daemons
68
68
 
69
- VERSION = "1.1.0"
69
+ VERSION = "1.1.1"
70
70
 
71
71
  require 'daemons/daemonize'
72
72
 
@@ -97,7 +97,7 @@ module Daemons
97
97
  # If not given, ARGV (the parameters given to the Ruby process) will be used.
98
98
  # <tt>:dir_mode</tt>:: Either <tt>:script</tt> (the directory for writing the pid files to
99
99
  # given by <tt>:dir</tt> is interpreted relative
100
- # to the script location given by +script+) or <tt>:normal</tt> (the directory given by
100
+ # to the script location given by +script+, the default) or <tt>:normal</tt> (the directory given by
101
101
  # <tt>:dir</tt> is interpreted as a (absolute or relative) path) or <tt>:system</tt>
102
102
  # (<tt>/var/run</tt> is used as the pid file directory)
103
103
  #
@@ -112,6 +112,8 @@ module Daemons
112
112
  # <tt>:backtrace</tt>:: Write a backtrace of the last exceptions to the file '[app_name].log' in the
113
113
  # pid-file directory if the application exits due to an uncaught exception
114
114
  # <tt>:monitor</tt>:: Monitor the programs and restart crashed instances
115
+ # <tt>:log_dir</tt>:: A specific directory to put the log files into (when not given, resort to the default
116
+ # location as derived from the :dir_mode and :dir options
115
117
  # <tt>:log_output</tt>:: When given (i.e. set to true), redirect both STDOUT and STDERR to a logfile named '[app_name].output' in the pid-file directory
116
118
  # <tt>:keep_pid_files</tt>:: When given do not delete lingering pid-files (files for which the process is no longer running).
117
119
  # <tt>:hard_exit</tt>:: When given use exit! to end a daemons instead of exit (this will for example
@@ -184,7 +186,7 @@ module Daemons
184
186
  # we do not have a script location so the the :script :dir_mode cannot be used, change it to :normal
185
187
  if [nil, :script].include? options[:dir_mode]
186
188
  options[:dir_mode] = :normal
187
- options[:dir] = File.expand_path('.')
189
+ options[:dir] ||= File.expand_path('.')
188
190
  end
189
191
 
190
192
  @controller = Controller.new(options, options[:ARGV] || ARGV)
@@ -255,12 +257,27 @@ module Daemons
255
257
  # <tt>:ontop</tt>:: When given, stay on top, i.e. do not daemonize the application
256
258
  # <tt>:backtrace</tt>:: Write a backtrace of the last exceptions to the file '[app_name].log' in the
257
259
  # pid-file directory if the application exits due to an uncaught exception
260
+ # <tt>:app_name</tt>:: The name of the application. This will be
261
+ # used to contruct the name of the pid files
262
+ # and log files. Defaults to the basename of
263
+ # the script.
264
+ # <tt>:dir_mode</tt>:: Either <tt>:script</tt> (the directory for writing files to
265
+ # given by <tt>:dir</tt> is interpreted relative
266
+ # to the script location given by +script+, the default) or <tt>:normal</tt> (the directory given by
267
+ # <tt>:dir</tt> is interpreted as a (absolute or relative) path) or <tt>:system</tt>
268
+ # (<tt>/var/run</tt> is used as the file directory)
269
+ #
270
+ # <tt>:dir</tt>:: Used in combination with <tt>:dir_mode</tt> (description above)
271
+ # <tt>:log_dir</tt>:: A specific directory to put the log files into (when not given, resort to the default
272
+ # location as derived from the :dir_mode and :dir options
273
+ # <tt>:log_output</tt>:: When given (i.e. set to true), redirect both STDOUT and STDERR to a logfile named '[app_name].output' in the pid-file directory
258
274
  # -----
259
275
  #
260
276
  # === Example:
261
277
  # options = {
262
278
  # :backtrace => true,
263
- # :ontop => true
279
+ # :ontop => true,
280
+ # :log_output => true
264
281
  # }
265
282
  #
266
283
  # Daemons.daemonize(options)
@@ -268,11 +285,14 @@ module Daemons
268
285
  # # Server loop:
269
286
  # loop {
270
287
  # conn = accept_conn()
288
+ # puts "some text which goes to the output logfile"
271
289
  # serve(conn)
272
290
  # }
273
291
  #
274
292
  def daemonize(options = {})
275
- @group ||= ApplicationGroup.new(options[:app_name] || 'self', options)
293
+ options[:script] ||= File.basename(__FILE__)
294
+
295
+ @group ||= ApplicationGroup.new(options[:app_name] || options[:script], options)
276
296
 
277
297
  @group.new_application(:mode => :none).start
278
298
  end
@@ -78,9 +78,9 @@ module Daemons
78
78
  # this function is only used to daemonize the currently running process (Daemons.daemonize)
79
79
  def start_none
80
80
  unless options[:ontop]
81
- Daemonize.daemonize(nil, @group.app_name) #(logfile)
81
+ Daemonize.daemonize(output_logfile, @group.app_name)
82
82
  else
83
- Daemonize.simulate
83
+ Daemonize.simulate(output_logfile)
84
84
  end
85
85
 
86
86
  @pid.pid = Process.pid
@@ -138,7 +138,6 @@ module Daemons
138
138
 
139
139
  started()
140
140
  Kernel.exec(script(), *(@app_argv || []))
141
- #Kernel.exec(script(), *ARGV)
142
141
  end
143
142
 
144
143
  def start_load
@@ -10,10 +10,8 @@ module Daemons
10
10
  @options = {}
11
11
 
12
12
  @opts = OptionParser.new do |opts|
13
- #opts.banner = "Usage: example.rb [options]"
14
13
  opts.banner = ""
15
14
 
16
- # Boolean switch.
17
15
  # opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
18
16
  # @options[:verbose] = v
19
17
  # end
@@ -37,8 +35,7 @@ module Daemons
37
35
  opts.separator ""
38
36
  opts.separator "Common options:"
39
37
 
40
- # No argument, shows at tail. This will print an options summary.
41
- # Try it and see!
38
+ # No argument, shows at tail. This will print an options summary
42
39
  opts.on_tail("-h", "--help", "Show this message") do
43
40
  #puts opts
44
41
  #@usage =
@@ -47,7 +44,7 @@ module Daemons
47
44
  exit
48
45
  end
49
46
 
50
- # Another typical switch to print the version.
47
+ # Switch to print the version.
51
48
  opts.on_tail("--version", "Show version") do
52
49
  puts "daemons version #{Daemons::VERSION}"
53
50
  exit
metadata CHANGED
@@ -1,19 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 2
10
+ version: 1.1.2
5
11
  platform: ruby
6
12
  authors:
7
13
  - Thomas Uehlinger
8
- autorequire: daemons
14
+ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-06-20 00:00:00 +02:00
18
+ date: 2011-03-29 00:00:00 +02:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
16
- description: " Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) \n to be run as a daemon and to be controlled by simple start/stop/restart commands.\n \n You can also call blocks as daemons and control them from the parent or just daemonize the current\n process.\n \n Besides this basic functionality, daemons offers many advanced features like exception \n backtracing and logging (in case your ruby script crashes) and monitoring and automatic\n restarting of your processes if they crash.\n"
22
+ description: Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart commands. You can also call blocks as daemons and control them from the parent or just daemonize the current process. Besides this basic functionality, daemons offers many advanced features like exception backtracing and logging (in case your ruby script crashes) and monitoring and automatic restarting of your processes if they crash.
17
23
  email: th.uehlinger@gmx.ch
18
24
  executables: []
19
25
 
@@ -43,8 +49,6 @@ files:
43
49
  - lib/daemons/pid.rb
44
50
  - lib/daemons/pidfile.rb
45
51
  - lib/daemons/exceptions.rb
46
- - examples/call/call.rb
47
- - examples/call/call_monitor.rb
48
52
  - examples/run/ctrl_normal.rb
49
53
  - examples/run/ctrl_monitor.rb
50
54
  - examples/run/ctrl_proc.rb
@@ -55,16 +59,15 @@ files:
55
59
  - examples/run/ctrl_exit.rb
56
60
  - examples/run/myserver_crashing.rb
57
61
  - examples/run/ctrl_proc_multiple.rb
58
- - examples/run/ctrl_proc.rb.output
59
62
  - examples/run/ctrl_keep_pid_files.rb
60
63
  - examples/run/ctrl_proc_simple.rb
61
64
  - examples/run/ctrl_ontop.rb
62
65
  - examples/run/ctrl_crash.rb
63
66
  - examples/run/ctrl_exec.rb
64
67
  - examples/run/ctrl_hanging.rb
65
- - examples/run/myserver_crashing.rb.output
66
- - examples/run/ctrl_proc_multiple.rb.output
67
68
  - examples/run/myserver_exiting.rb
69
+ - examples/call/call.rb
70
+ - examples/call/call_monitor.rb
68
71
  - examples/daemonize/daemonize.rb
69
72
  has_rdoc: true
70
73
  homepage: http://daemons.rubyforge.org
@@ -76,23 +79,29 @@ rdoc_options: []
76
79
  require_paths:
77
80
  - lib
78
81
  required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
79
83
  requirements:
80
84
  - - ">="
81
85
  - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
82
89
  version: "0"
83
- version:
84
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
85
92
  requirements:
86
93
  - - ">="
87
94
  - !ruby/object:Gem::Version
95
+ hash: 3
96
+ segments:
97
+ - 0
88
98
  version: "0"
89
- version:
90
99
  requirements: []
91
100
 
92
101
  rubyforge_project: daemons
93
- rubygems_version: 1.3.5
102
+ rubygems_version: 1.6.2
94
103
  signing_key:
95
- specification_version: 3
104
+ specification_version: 2
96
105
  summary: A toolkit to create and control daemons in different ways
97
106
  test_files: []
98
107
 
@@ -1,101 +0,0 @@
1
- ping from proc!
2
- ping from proc!
3
- ping from proc!
4
- ping from proc!
5
- ping from proc!
6
- ping from proc!
7
- ping from proc!
8
- ping from proc!
9
- ping from proc!
10
- ping from proc!
11
- ping from proc!
12
- ping from proc!
13
- ping from proc!
14
- ping from proc!
15
- ping from proc!
16
- ping from proc!
17
- ping from proc!
18
- ping from proc!
19
- ping from proc!
20
- ping from proc!
21
- ping from proc!
22
- ping from proc!
23
- ping from proc!
24
- ping from proc!
25
- ping from proc!
26
- ping from proc!
27
- ping from proc!
28
- ping from proc!
29
- ping from proc!
30
- ping from proc!
31
- ping from proc!
32
- ping from proc!
33
- ping from proc!
34
- ping from proc!
35
- ping from proc!
36
- ping from proc!
37
- ping from proc!
38
- ping from proc!
39
- ping from proc!
40
- ping from proc!
41
- ping from proc!
42
- ping from proc!
43
- ping from proc!
44
- ping from proc!
45
- ping from proc!
46
- ping from proc!
47
- ping from proc!
48
- ping from proc!
49
- ping from proc!
50
- ping from proc!
51
- ping from proc!
52
- ping from proc!
53
- ping from proc!
54
- ping from proc!
55
- ping from proc!
56
- ping from proc!
57
- ping from proc!
58
- ping from proc!
59
- ping from proc!
60
- ping from proc!
61
- ping from proc!
62
- ping from proc!
63
- ping from proc!
64
- ping from proc!
65
- ping from proc!
66
- ping from proc!
67
- ping from proc!
68
- ping from proc!
69
- ping from proc!
70
- ping from proc!
71
- ping from proc!
72
- ping from proc!
73
- ping from proc!
74
- ping from proc!
75
- ping from proc!
76
- ping from proc!
77
- ping from proc!
78
- ping from proc!
79
- ping from proc!
80
- ping from proc!
81
- ping from proc!
82
- ping from proc!
83
- ping from proc!
84
- ping from proc!
85
- ping from proc!
86
- ping from proc!
87
- ping from proc!
88
- ping from proc!
89
- ping from proc!
90
- ping from proc!
91
- ping from proc!
92
- ping from proc!
93
- ping from proc!
94
- ping from proc!
95
- ping from proc!
96
- ping from proc!
97
- ping from proc!
98
- ping from proc!
99
- ping from proc!
100
- ping from proc!
101
- ping from proc!
@@ -1,2 +0,0 @@
1
-
2
- hello
@@ -1,30 +0,0 @@
1
- /home/uehli/Desktop/daemons-current/examples/myserver_crashing.rb:13: CRASH! (RuntimeError)
2
- from /home/uehli/Desktop/daemons-current/examples/myserver_crashing.rb:6:in `loop'
3
- from /home/uehli/Desktop/daemons-current/examples/myserver_crashing.rb:6
4
- from /home/uehli/Desktop/daemons-current/lib/daemons.rb:116:in `load'
5
- from /home/uehli/Desktop/daemons-current/lib/daemons.rb:116:in `run_via_load'
6
- from /home/uehli/Desktop/daemons-current/lib/daemons.rb:90:in `start'
7
- from /home/uehli/Desktop/daemons-current/lib/daemons.rb:359:in `run'
8
- from /home/uehli/Desktop/daemons-current/lib/daemons.rb:469:in `run'
9
- from /home/uehli/Desktop/daemons-current/lib/daemons.rb:468:in `call'
10
- from /home/uehli/Desktop/daemons-current/lib/daemons/cmdline.rb:94:in `catch_exceptions'
11
- from /home/uehli/Desktop/daemons-current/lib/daemons.rb:468:in `run'
12
- from ctrl_crash.rb:17
13
- ping from myserver.rb!
14
- this example server will crash in 3 seconds...
15
- CRASH!
16
- ping from myserver.rb!
17
- this example server will crash in 3 seconds...
18
- CRASH!
19
- /Users/uehli/Projects/daemons-proj/examples/run/myserver_crashing.rb:13: CRASH! (RuntimeError)
20
- from /Users/uehli/Projects/daemons-proj/examples/run/myserver_crashing.rb:6:in `loop'
21
- from /Users/uehli/Projects/daemons-proj/examples/run/myserver_crashing.rb:6
22
- from /Users/uehli/Projects/daemons-proj/lib/daemons/application.rb:176:in `load'
23
- from /Users/uehli/Projects/daemons-proj/lib/daemons/application.rb:176:in `start_load'
24
- from /Users/uehli/Projects/daemons-proj/lib/daemons/application.rb:257:in `start'
25
- from /Users/uehli/Projects/daemons-proj/lib/daemons/controller.rb:69:in `run'
26
- from /Users/uehli/Projects/daemons-proj/lib/daemons.rb:139:in `run'
27
- from /Users/uehli/Projects/daemons-proj/lib/daemons/cmdline.rb:105:in `call'
28
- from /Users/uehli/Projects/daemons-proj/lib/daemons/cmdline.rb:105:in `catch_exceptions'
29
- from /Users/uehli/Projects/daemons-proj/lib/daemons.rb:138:in `run'
30
- from ctrl_crash.rb:17