FiXato-daemons 1.0.10.2

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/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2005-2007 Thomas Uehlinger
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
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,242 @@
1
+ = Quick'n'dirty Daemons Version 1.0.10 gem with fix by Chris Kline
2
+
3
+ This is a clean import of Daemons 1.0.10, with the following changes:
4
+
5
+ # Applied Chris Kline's patch to "Making sure Ruby Daemons die" from http://blog.rapleaf.com/dev/?p=19.
6
+ # Added a gemspec to allow Github to build a gem.
7
+
8
+ = Daemons Version 1.0.10
9
+
10
+ (See Releases for release-specific information)
11
+
12
+ == What is Daemons?
13
+
14
+ Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server)
15
+ to be <i>run as a daemon</i> and to be <i>controlled by simple start/stop/restart commands</i>.
16
+
17
+ If you want, you can also use daemons to <i>run blocks of ruby code in a daemon process</i> and to control
18
+ these processes from the main application.
19
+
20
+ Besides this basic functionality, daemons offers many advanced features like <i>exception backtracing</i>
21
+ and logging (in case your ruby script crashes) and <i>monitoring</i> and automatic restarting of your processes
22
+ if they crash.
23
+
24
+ Daemons includes the <tt>daemonize.rb</tt> script written by <i>Travis Whitton</i> to do the daemonization
25
+ process.
26
+
27
+ == Basic Usage
28
+
29
+ You can use Daemons in four differet ways:
30
+
31
+ === 1. Create wrapper scripts for your server scripts or applications
32
+
33
+ Layout: suppose you have your self-written server <tt>myserver.rb</tt>:
34
+
35
+ # this is myserver.rb
36
+ # it does nothing really useful at the moment
37
+
38
+ loop do
39
+ sleep(5)
40
+ end
41
+
42
+ To use <tt>myserver.rb</tt> in a production environment, you need to be able to
43
+ run <tt>myserver.rb</tt> in the _background_ (this means detach it from the console, fork it
44
+ in the background, release all directories and file descriptors).
45
+
46
+ Just create <tt>myserver_control.rb</tt> like this:
47
+
48
+ # this is myserver_control.rb
49
+
50
+ require 'rubygems' # if you use RubyGems
51
+ require 'daemons'
52
+
53
+ Daemons.run('myserver.rb')
54
+
55
+ And use it like this from the console:
56
+
57
+ $ ruby myserver_control.rb start
58
+ (myserver.rb is now running in the background)
59
+ $ ruby myserver_control.rb restart
60
+ (...)
61
+ $ ruby myserver_control.rb stop
62
+
63
+ For testing purposes you can even run <tt>myserver.rb</tt> <i>without forking</i> in the background:
64
+
65
+ $ ruby myserver_control.rb run
66
+
67
+ An additional nice feature of Daemons is that you can pass <i>additional arguments</i> to the script that
68
+ should be daemonized by seperating them by two _hyphens_:
69
+
70
+ $ ruby myserver_control.rb start -- --file=anyfile --a_switch another_argument
71
+
72
+
73
+ === 2. Create wrapper scripts that include your server procs
74
+
75
+ Layout: suppose you have some code you want to run in the background and control that background process
76
+ from a script:
77
+
78
+ # this is your code
79
+ # it does nothing really useful at the moment
80
+
81
+ loop do
82
+ sleep(5)
83
+ end
84
+
85
+ To run this code as a daemon create <tt>myproc_control.rb</tt> like this and include your code:
86
+
87
+ # this is myproc_control.rb
88
+
89
+ require 'rubygems' # if you use RubyGems
90
+ require 'daemons'
91
+
92
+ Daemons.run_proc('myproc.rb') do
93
+ loop do
94
+ sleep(5)
95
+ end
96
+ end
97
+
98
+ And use it like this from the console:
99
+
100
+ $ ruby myproc_control.rb start
101
+ (myproc.rb is now running in the background)
102
+ $ ruby myproc_control.rb restart
103
+ (...)
104
+ $ ruby myproc_control.rb stop
105
+
106
+ For testing purposes you can even run <tt>myproc.rb</tt> <i>without forking</i> in the background:
107
+
108
+ $ ruby myproc_control.rb run
109
+
110
+ === 3. Control a bunch of daemons from another application
111
+
112
+ Layout: you have an application <tt>my_app.rb</tt> that wants to run a bunch of
113
+ server tasks as daemon processes.
114
+
115
+ # this is my_app.rb
116
+
117
+ require 'rubygems' # if you use RubyGems
118
+ require 'daemons'
119
+
120
+ task1 = Daemons.call(:multiple => true) do
121
+ # first server task
122
+
123
+ loop {
124
+ conn = accept_conn()
125
+ serve(conn)
126
+ }
127
+ end
128
+
129
+ task2 = Daemons.call do
130
+ # second server task
131
+
132
+ loop {
133
+ something_different()
134
+ }
135
+ end
136
+
137
+ # the parent process continues to run
138
+
139
+ # we can even control our tasks, for example stop them
140
+ task1.stop
141
+ task2.stop
142
+
143
+ exit
144
+
145
+ === 4. Daemonize the currently running process
146
+
147
+ Layout: you have an application <tt>my_daemon.rb</tt> that wants to run as a daemon
148
+ (but without the ability to be controlled by daemons via start/stop commands)
149
+
150
+ # this is my_daemons.rb
151
+
152
+ require 'rubygems' # if you use RubyGems
153
+ require 'daemons'
154
+
155
+ # Initialize the app while we're not a daemon
156
+ init()
157
+
158
+ # Become a daemon
159
+ Daemons.daemonize
160
+
161
+ # The server loop
162
+ loop {
163
+ conn = accept_conn()
164
+ serve(conn)
165
+ }
166
+
167
+
168
+ <b>For further documentation, refer to the module documentation of Daemons.</b>
169
+
170
+
171
+ == Installation from Github
172
+ $ git clone git://github.com/FiXato/daemons.git
173
+ $ cd daemons
174
+ $ rake install
175
+
176
+ This will clone this repository, build the gem and (sudo) install it.
177
+
178
+ Or if you want to install the gem directly from the Github gem repository:
179
+ $ gem sources -a http://gems.github.com
180
+ $ gem install FiXato-daemons
181
+
182
+
183
+ == Download and Installation (Rubyforge)
184
+
185
+ *Download*: just go to http://rubyforge.org/projects/daemons/
186
+
187
+ Installation *with* RubyGems:
188
+ $ su
189
+ # gem install daemons
190
+
191
+ Installation *without* RubyGems:
192
+ $ tar xfz daemons-x.x.x.tar.gz
193
+ $ cd daemons-x.x.x
194
+ $ su
195
+ # ruby setup.rb
196
+
197
+ == Documentation
198
+
199
+ For further documentation, refer to the module documentation of Daemons (click on Daemons).
200
+
201
+ The RDoc documentation is also online at http://daemons.rubyforge.org
202
+
203
+
204
+ == Author
205
+
206
+ Written in 2005-2008 by Thomas Uehlinger <mailto:th.uehlinger@gmx.ch>.
207
+
208
+ == License
209
+
210
+ Copyright (c) 2005-2008 Thomas Uehlinger
211
+
212
+ Permission is hereby granted, free of charge, to any person
213
+ obtaining a copy of this software and associated documentation
214
+ files (the "Software"), to deal in the Software without
215
+ restriction, including without limitation the rights to use,
216
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
217
+ copies of the Software, and to permit persons to whom the
218
+ Software is furnished to do so, subject to the following
219
+ conditions:
220
+
221
+ The above copyright notice and this permission notice shall be
222
+ included in all copies or substantial portions of the Software.
223
+
224
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
225
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
226
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
227
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
228
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
229
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
230
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
231
+ OTHER DEALINGS IN THE SOFTWARE.
232
+
233
+ This license does not apply to daemonize.rb, which is was written by
234
+ Travis Whitton und published under the following license:
235
+
236
+ The Daemonize extension module is copywrited free software by Travis Whitton
237
+ <whitton@atlantic.net>. You can redistribute it under the terms specified in
238
+ the COPYING file of the Ruby distribution.
239
+
240
+ == Feedback and other resources
241
+
242
+ At http://rubyforge.org/projects/daemons.
@@ -0,0 +1,38 @@
1
+ require "rake"
2
+ require "rake/clean"
3
+ require "rake/gempackagetask"
4
+ require 'rake/rdoctask'
5
+ require 'rubygems'
6
+
7
+ ################################################################################
8
+ ### Gem
9
+ ################################################################################
10
+
11
+ begin
12
+ # Parse gemspec using the github safety level.
13
+ file = Dir['*.gemspec'].first
14
+ data = File.read(file)
15
+ spec = nil
16
+ Thread.new { spec = eval("$SAFE = 3\n%s" % data)}.join
17
+
18
+ # Create the gem tasks
19
+ Rake::GemPackageTask.new(spec) do |package|
20
+ package.gem_spec = spec
21
+ end
22
+ rescue Exception => e
23
+ printf "WARNING: Error caught (%s): %s\n%s", e.class.name, e.message, e.backtrace[0...5].map {|l| ' %s' % l}.join("\n")
24
+ end
25
+
26
+ desc "Create the RDOC html files"
27
+ rd = Rake::RDocTask.new("rdoc") { |rdoc|
28
+ rdoc.rdoc_dir = 'html'
29
+ rdoc.title = "Daemons"
30
+ rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc'
31
+ rdoc.rdoc_files.include('README.rdoc', 'TODO', 'Releases')
32
+ rdoc.rdoc_files.include('lib/**/*.rb')
33
+ }
34
+
35
+ desc 'Package and install the gem for the current version'
36
+ task :install => :gem do
37
+ system "sudo gem install -l pkg/%s-%s.gem" % [spec.name, spec.version]
38
+ end
@@ -0,0 +1,133 @@
1
+ = Daemons Release History
2
+
3
+ == Release 1.0.10.2: March 17, 2009
4
+ * Cleaned up gemspec and Rakefile.
5
+ * Added `rake install` task.
6
+
7
+ == Release 1.0.10.1: March 17, 2009
8
+ * Fixed version numbers.
9
+
10
+ == Release 1.0.10: November 16, 2007
11
+
12
+ * By default, we now delete stray pid-files (i.e. pid-files which result for
13
+ example from a killed daemon) automatically. This function can be deactivated by
14
+ passing :keep_pid_files => true as an option.
15
+ * All pid files of :multiple daemons new get deleted correctly upon exit of the daemons (reported by Han Holl).
16
+ * Use the signal 'KILL' instead of 'TERM' on Windows platforms.
17
+ * Use exit! in trap('TERM') instead of exit when option :hard_exit is given (thanks to Han Holl).
18
+ * Did some clarification on the exception log.
19
+
20
+ == Release 1.0.9: October 29, 2007
21
+
22
+ * fixed a severe bug in the new Pid.running? function: function returned true if the process did not exist (thanks to Jeremy Lawler).
23
+
24
+ == Release 1.0.8: September 24, 2007
25
+
26
+ * new Pid.running? function. Checking whether a process exists by sending signal '0' (thanks to Dru Nelson).
27
+
28
+ == Release 1.0.7: July 7, 2007
29
+
30
+ * Patch to fix wrong ARGV when using :exec (in def start_exec: Kernel.exec(script(), *(@app_argv || []))) (thanks to Alex McGuire).
31
+
32
+ == Release 1.0.6: Mai 8, 2007
33
+
34
+ * New option to pass an ARGV-style array to run and run_proc (thanks to Marc Evans).
35
+ * Additional patches for '/var/log' (thanks to Marc Evans).
36
+
37
+ == Release 1.0.5: February 24, 2007
38
+
39
+ * Applied patch that makes daemons to use '/var/log' as logfile
40
+ directory if you use :dir_mode = :system (thanks to Han Holl).
41
+ * Daemons should now work with Ruby 1.9 (at least the basic features).
42
+
43
+ == Release 1.0.4: January 17, 2007
44
+
45
+ * Document the :log_output option (thanks to Andrew Kuklewicz).
46
+ * Set STDOUT.sync = true when redirecting to a logfile (thanks to Andrew Kuklewicz).
47
+ * Should now run also correctly when there is no working 'ps ax' on the system (thanks to Daniel Kehoe).
48
+
49
+ == Release 1.0.3: November 1, 2006
50
+
51
+ * Set the app_name correctly also for the monitor process (thanks to Ilya Novoselov).
52
+
53
+ == Release 1.0.2: September 26, 2006
54
+
55
+ * Changed the 'ps -ax' call back to 'ps ax'.
56
+ * Fixed the documentation for the :normal :dir_mode.
57
+ * As a default for Daemons.run_proc, the pid file is now saved in the current directory.
58
+ * In :ontop mode for running a proc (this is equal to calling something like 'ruby ctrl_proc.rb run'),
59
+ the proc now runs directly in the calling script, not in a forked process anymore (thanks to Paul Butcher).
60
+ * Set $0 to app_name in the daemons (thanks to Ilya Novoselov).
61
+
62
+ == Release 1.0.1: August 30, 2006
63
+
64
+ * Fixed a regex for parsing the 'ps ax' system call. (thanks to Garance Alistair Drosehn)
65
+
66
+ == Release 1.0.0: August 29, 2006
67
+
68
+ * Fix the parsing of the 'ps ax' system call. (thanks to Garance Alistair Drosehn)
69
+
70
+ == Release 0.4.4: February 14, 2006
71
+
72
+ * Several fixes that allow us to use the Daemons::Controller
73
+ with a proc instead of wrapping a script file. This gives us all the
74
+ PID file management, monitoring, command line options, etc. without having
75
+ to specify a path to our script which can be tricky, especially when using
76
+ RubyGems. (thanks to John-Mason Shackelford)
77
+
78
+ == Release 0.4.3: November 29, 2005
79
+
80
+ * New Option: You can specify the name of the application with :app_name
81
+ on calling Daemons.run. This will be used to contruct the name of the pid files
82
+ and log files. Defaults to the basename of the script. (thanks to Stephen R. Veit)
83
+
84
+ * Bugfix: Handle the case where no controller options are given when calling Daemons,
85
+ just options after "--". (thanks to Stephen R. Veit)
86
+
87
+
88
+ == Release 0.4.2: November 15, 2005
89
+
90
+ * Bugfix for problem with :normal pid-file directory mode (pid.rb), fixed (thanks to Stephen R. Veit)
91
+
92
+
93
+ == Release 0.4.1: September 11, 2005
94
+
95
+ * Bugfix for 'run' command line mode: didn't work anymore in 0.4.0, fixed
96
+
97
+
98
+ == Release 0.4.0: July 30, 2005
99
+
100
+ * Two completely new operation modes:
101
+ 1. Call a block as a daemon (<tt>Daemons.call { my_daemon_code }</tt>)
102
+ and control it from the parent process.
103
+ 2. Daemonize the currently running process (<tt>Daemons.daemonize</tt>)
104
+ plus the already existing mode to control your scripts (<tt>Daemons.run("script.rb")</tt>)
105
+ * Improved documentation (for example "How does the daemonization process work?")
106
+ * Improved "simulation mode" (<tt>:ontop</tt> option)
107
+ * Some minor bugfixes
108
+
109
+
110
+ == Release 0.3.0: April 21, 2005
111
+
112
+ * New monitor functionality: automatic restarting of your applications if they crash
113
+ * 'restart' command fixed
114
+ * '--force' command modifier (please refer to the documentation)
115
+ * Some more bugfixes and improvements
116
+
117
+
118
+ == Release 0.2.1: Mar 21, 2005
119
+
120
+ * Bugfix for a problem with the 'status' command
121
+
122
+
123
+ == Release 0.2.0: Mar 21, 2005
124
+
125
+ * Exception backtrace functionality added
126
+ * Exec functionality added
127
+ * More examples added
128
+ * New commands: status, zap
129
+
130
+
131
+ == Release 0.0.1: Feb 8, 2005
132
+
133
+ * Initial release
data/TODO ADDED
@@ -0,0 +1,6 @@
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)
6
+