Skip to content

Commit

Permalink
sync with main repo, tweak rakefile(s) again for better win32 gem, ne…
Browse files Browse the repository at this point in the history
…ed to handle not forking in win32 from the executable script (daemons doesn't work on win32)
  • Loading branch information
kevwil committed Jan 17, 2008
1 parent a4b49dc commit 6134e43
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 193 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -8,5 +8,3 @@ log/*.log
doc/rdoc/*
tmp/*
pkg/*
Manifest
nbproject/*
45 changes: 36 additions & 9 deletions CHANGELOG
@@ -1,11 +1,38 @@
v0.5.3. Purple Yogurt release
== 0.5.3 Purple Yogurt release
* Add prefix option to thin script to mount app under a given path.

v0.5.2. Cheezburger release
== 0.5.2 Cheezburger release
* Add cluster support through the -s option in the thin script, start 3 thins like this:
thin start -s3 -p3000
3 thin servers will be started on port 3000, 3001, 3002, also the port number will be
injected in the pid and log filenames.
* Fix IOError when writing to logger when starting server as a daemon.
* Really change directory when the -c option is specified.
* Add restart command to thin script.
* Fix typos in thin script usage message and expand chdir path.
* Rename thin script options to be the same as mongrel_rails script [thronedrk]:
-o --host => -a --address
--log-file => --log
--pid-file => --pid
--env => --environment

== 0.5.1 LOLCAT release
* Add URL rewriting to Rails adapter so that page caching works and / fetches index.html if present.
* Fix bug in multiline response header parsing.
* Add specs for the Rails adapter.
* Fix Set-Cookie headers in Rails adapter to handle multiple values correctly.
* Fix Ruby 1.9 incompatibility in Response#headers= and Rakefile.
* Fix parser to be Ruby 1.9 compatible [Aman Gupta]
* Set gemspec to use EventMachine version 0.8.1 as it's the latest one having precompiled windows binaries.
[Francis Cianfrocca].
* Add -D option to thin script to set debugging on.
* Output incoming data and response when debugging is on.

v0.5.1. LOLCAT release

v0.5.0. full rewrite to use EventMachine, Rack, and Mongrel parser

v0.4.1. Fix Rails environment option not being used in thin script.

v0.4.0. First alphaish release as a gem.
== 0.5.0
* Full rewrite to use EventMachine, Rack and Mongrel parser

== 0.4.1
* Fix Rails environment option not being used in thin script.

== 0.4.0
* First alphaish release as a gem.
3 changes: 3 additions & 0 deletions COMMITTERS
@@ -0,0 +1,3 @@
Marc-Andre Cournoyer <macournoyer@gmail.com>
Kevin Williams <kevwil@gmail.com>
James Golick
File renamed without changes.
171 changes: 7 additions & 164 deletions Rakefile
@@ -1,168 +1,11 @@
require 'lib/thin'
require 'echoe'

# sudo flag
windows = (PLATFORM =~ /mswin|cygwin/)
SUDO = windows ? "" : "sudo"

# ruby version
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
def gem
RUBY_1_9 ? 'gem19' : 'gem'
end

# ragel
RAGEL_BASE = 'parser'
RAGEL_TARGET = "#{RAGEL_BASE}.c"
RAGEL_FILE = "#{RAGEL_BASE}.rl"

# ext
EXT_BASE = 'thin_parser'
EXT_DIR = "ext/#{EXT_BASE}"
EXT_BUNDLE = "#{EXT_DIR}/#{EXT_BASE}.#{Config::CONFIG['DLEXT']}"
SO_FILE = "#{EXT_BASE}.so"

Echoe.new(Thin::NAME) do |p|
p.author = "Marc-Andre Cournoyer"
p.email = "macournoyer@gmail.com"
p.description = "Thin takes the http parser from Mongrel, the
connection engine from EventMachine and the web server interface
from Rack, creating a highly flexible, small, fast, and sexy
web app server for Ruby."
p.summary = "A thin and fast web server"
p.url = "http://code.macournoyer.com/thin/"
p.docs_host = "macournoyer.com:~/code.macournoyer.com/thin/doc/"
p.clean_pattern = ['ext/thin_parser/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'lib/*.{bundle,so,o,obj,pdb,lib,def,exp}', 'ext/thin_parser/Makefile', 'pkg', 'lib/*.bundle', '*.gem', '*.gemspec', '.config', 'coverage']
p.ignore_pattern = /^(.git|benchmark|site|tasks)|.gitignore/
p.rdoc_pattern = ['README', 'LICENSE', 'changes.txt', 'lib/**/*.rb', 'doc/**/*.rdoc']
p.ruby_version = '>= 1.8.6'
p.dependencies = ['rack >= 0.2.0']
p.extension_pattern = nil
p.need_tar_gz = false

if RUBY_PLATFORM !~ /mswin/
p.extension_pattern = ["ext/**/extconf.rb"]
end

p.eval = proc do
case RUBY_PLATFORM
when /mswin/
self.files += ['lib/thin_parser.so']
add_dependency('eventmachine', '>= 0.8.1')
else
add_dependency('daemons', '>= 1.0.9')
add_dependency('eventmachine')
end
end
end

task :clean => :clobber_package

task :tag_warn do
puts "*" * 40
puts "Don't forget to tag the release:"
puts " git tag -a v#{Thin::VERSION::STRING}"
puts "*" * 40
end

task :gem => [:compile,:tag_warn]
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
WIN = (PLATFORM =~ /mswin|cygwin/)
SUDO = (WIN ? "" : "sudo")

desc "Compile the Ragel state machines"
task :ragel do
Dir.chdir EXT_DIR do
File.unlink RAGEL_TARGET if File.exist? RAGEL_TARGET
sh "ragel #{RAGEL_FILE} | rlgen-cd -G2 -o #{RAGEL_TARGET}"
raise "Failed to compile Ragel state machine" unless File.exist? RAGEL_TARGET
end
end

case RUBY_PLATFORM
when /mswin/
FILENAME = "lib/#{SO_FILE}"
file FILENAME do
Dir.chdir EXT_DIR do
ruby "extconf.rb"
system('nmake')
end
cp EXT_BUNDLE, 'lib/'
end
desc "compile mswin32 extension"
task :compile => [FILENAME]
else
# task :compile defined by echoe due to defined extension_pattern
end

namespace :deploy do
task :site => %w(site:upload rdoc:upload)

desc 'Deploy on code.macournoyer.com'
task :alpha => %w(gem:upload deploy:site)

desc 'Deploy on rubyforge'
task :public => %w(gem:upload_rubyforge deploy:site)
end
desc 'Deploy on all servers'
task :deploy => %w(deploy:alpha deploy:public)

def upload(file, to, options={})
sh %{ssh macournoyer@macournoyer.com "rm -rf code.macournoyer.com/#{to}"} if options[:replace]
sh %{scp -rq #{file} macournoyer@macournoyer.com:code.macournoyer.com/#{to}}
end

namespace :site do
task :build do
mkdir_p 'tmp/site/images'
cd 'tmp/site' do
sh "SITE_ROOT='/thin' ruby ../../site/thin.rb --dump"
end
cp 'site/style.css', 'tmp/site'
cp_r Dir['site/images/*'], 'tmp/site/images'
end

desc 'Upload website to code.macournoyer.com'
task :upload => 'site:build' do
upload 'tmp/site/*', 'thin'
end
end
require 'rake'
require 'rake/clean'
require 'lib/thin'

if RUBY_1_9
task :spec do
warn 'RSpec not yet supporting Ruby 1.9, so cannot run the specs :('
end
else
# RSpec not yet working w/ Ruby 1.9
require 'spec/rake/spectask'

desc "Run all examples"
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
end
end
Dir['tasks/**/*.rake'].each { |rake| load rake }

task :default => [:compile, :spec]

desc 'Show some stats about the code'
task :stats do
line_count = proc do |path|
Dir[path].collect { |f| File.open(f).readlines.reject { |l| l =~ /(^\s*(\#|\/\*))|^\s*$/ }.size }.inject(0){ |sum,n| sum += n }
end
lib = line_count['lib/**/*.rb']
ext = line_count['ext/**/*.{c,h}']
spec = line_count['spec/**/*.rb']
ratio = '%1.2f' % (spec.to_f / lib.to_f)

puts "#{lib.to_s.rjust(6)} LOC of lib"
puts "#{ext.to_s.rjust(6)} LOC of ext"
puts "#{spec.to_s.rjust(6)} LOC of spec"
puts "#{ratio.to_s.rjust(6)} ratio lib/spec"
end

desc "install the gem"
task :thin_install => [:clean,:package] do
sh %{#{SUDO} #{gem} install pkg/#{Thin::NAME}-#{Thin::VERSION::STRING}*.gem --no-update-sources}
end

desc "uninstall the gem"
task :thin_uninstall => :clean do
sh %{#{SUDO} #{gem} uninstall #{Thin::NAME}}
end
18 changes: 11 additions & 7 deletions TODO
@@ -1,17 +1,21 @@
== BUGS
* Carl Mercier is experiencing weird stuff, response headers seems to be happened
to the top of every HTML page in the browser ?wtf?
* Thin uses more memory then Mongrel on some apps, investigate why

== FEATURES
* Add --prefix option to thin script
* IPv6 support (bind to ::1)
* IPv6 support (should be able to bind to ::1)

== TASKS
* Add a better god sample file in example, maybe generate one !?
* Change benchmarking test to use
http://blog.evanweaver.com/files/doc/fauna/benchmark_unit/
* Provide precompiled win32 binaries in Gem
* Load options from a config file
* Create a Stats adapter to show server stats in the browser
* Check for memory usage/leaks using dike or other.
* Change benchmarking tests to use
http://blog.evanweaver.com/files/doc/fauna/benchmark_unit/
* Add a better god sample file in example/,
maybe generate one w/ thin config and use this in replacement
of mongrel_cluster to launch cluster at startup and all.
* Port response writing to a C extension
* Benchmark CGI and FastCGI too [Carlos Junior]
* Investigate http://rev.rubyforge.org/ (only Ruby 1.9)
* Check for memory usage/leaks using dike or other.
* Benchmark CGI and FastCGI too [Carlos Junior]
File renamed without changes.
4 changes: 3 additions & 1 deletion site/thin.rb
Expand Up @@ -138,7 +138,9 @@ def users_page
li { a "Kevin Williams Blog", :href => 'http://www.almostserio.us/articles/2008/01/11/thin-web-server-for-ruby-rocks' }
li { a "Dinooz", :href => 'http://www.nicomoayudarte.com/' }
li { a "Mobile Dyne Systems", :href => 'http://www.mobiledyne.com/' }
li { a "Mobile Dyne Systems", :href => 'http://feelfree.homelinux.com' }
li { a "feelfree.homelinux.com", :href => 'http://feelfree.homelinux.com' }
li { a "to2posts.com", :href => 'http://to2blogs.com/' }
li { a "James on Software", :href => 'http://jamesgolick.com/' }
end

p { "If you'd like to have your site listed here, #{a 'drop me an email', :href => 'mailto:macournoyer@gmail.com'}" }
Expand Down
25 changes: 16 additions & 9 deletions tasks/gem.rake
Expand Up @@ -15,13 +15,11 @@ spec = Gem::Specification.new do |s|

s.required_ruby_version = '>= 1.8.6' # Makes sure the CGI eof fix is there

if WIN
s.add_dependency 'eventmachine', '>= 0.8.1' # Latest precompiled version released
else
s.add_dependency 'eventmachine'
s.add_dependency 'daemons', '>= 1.0.9' # Daemonizing doesn't work on win
end
s.add_dependency 'rack', '>= 0.2.0'
s.add_dependency 'eventmachine', '>= 0.8.1'
unless WIN
s.add_dependency 'daemons', '>= 1.0.9'
end

s.files = %w(COPYING CHANGELOG README Rakefile) +
Dir.glob("{benchmark,bin,doc,example,lib,spec}/**/*") +
Expand Down Expand Up @@ -59,11 +57,20 @@ namespace :gem do
desc 'Upload gem to rubyforge.org'
task :upload_rubyforge => :gem do
sh 'rubyforge login'
sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/thin-#{Thin::VERSION::STRING}.gem"
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/thin-#{Thin::VERSION::STRING}.gem"
sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
end
end

task :install => [:clobber, :compile, :package] do
sh "#{SUDO} #{gem} install pkg/#{spec.full_name}.gem"
end

task :uninstall => :clean do
sh "#{SUDO} #{gem} uninstall -v #{Thin::VERSION::STRING} -x #{Thin::NAME}"
end


def gem
RUBY_1_9 ? 'gem19' : 'gem'
end
end
2 changes: 1 addition & 1 deletion tasks/spec.rake
Expand Up @@ -12,4 +12,4 @@ else
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
end
end
end

0 comments on commit 6134e43

Please sign in to comment.