mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04: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:
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user