1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixed that spawner should daemonize if running in repeat mode [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4135 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2006-04-03 03:03:33 +00:00
parent 0b167dd863
commit f966c279cf
3 changed files with 18 additions and 3 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Fixed that spawner should daemonize if running in repeat mode [DHH]
* Added TAG option for rake rails:freeze:edge, so you can say rake rails:freeze:edge TAG=rel_1-1-0 to lock to the 1.1.0 release [DHH]
* Applied Prototype $() performance patches (#4465, #4477) and updated script.aculo.us [Sam Stephenson, Thomas Fuchs]

View file

@ -1,6 +1,17 @@
require 'optparse'
require 'socket'
def daemonize #:nodoc:
exit if fork # Parent exits, child continues.
Process.setsid # Become session leader.
exit if fork # Zap session leader. See [1].
Dir.chdir "/" # Release old working directory.
File.umask 0000 # Ensure sensible umask. Adjust as needed.
STDIN.reopen "/dev/null" # Free file descriptors and
STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
STDERR.reopen STDOUT # STDOUT/ERR should better go to a logfile.
end
def spawn(port)
print "Checking if something is already running on port #{port}..."
begin
@ -71,10 +82,12 @@ end
ENV["RAILS_ENV"] = OPTIONS[:environment]
if OPTIONS[:repeat]
daemonize
trap("TERM") { exit }
loop do
spawn_all
puts "Sleeping for #{OPTIONS[:repeat]} seconds"
sleep OPTIONS[:repeat]
sleep(OPTIONS[:repeat])
end
else
spawn_all

View file

@ -22,7 +22,7 @@ namespace :tmp do
end
namespace :sockets do
desc "Clears all ruby_sess.* files in tmp/sessions"
desc "Clears all files in tmp/sockets"
task :clear do
FileUtils.rm(Dir['tmp/sockets/[^.]*'])
end