move to AR

This commit is contained in:
Rick Okin 2005-08-09 02:20:28 +00:00
parent c4b7b2d9f2
commit 26c046cdfa
51 changed files with 2345 additions and 516 deletions

View file

@ -1,93 +1,49 @@
#!/usr/bin/ruby
#!/usr/local/bin/ruby
require 'webrick'
require 'optparse'
require 'fileutils'
pwd = File.expand_path(File.dirname(__FILE__) + "/..")
OPTIONS = {
# Overridable options
:port => 2500,
:ip => '0.0.0.0',
:environment => 'production',
:server_root => File.expand_path(File.dirname(__FILE__) + '/../public/'),
:server_type => WEBrick::SimpleServer,
:storage => "#{File.expand_path(FileUtils.pwd)}/storage",
:port => 3000,
:ip => "0.0.0.0",
:environment => "development",
:server_root => File.expand_path(File.dirname(__FILE__) + "/../public/"),
:server_type => WEBrick::SimpleServer
}
ARGV.options do |opts|
script_name = File.basename($0)
opts.banner = "Usage: ruby #{script_name} [options]"
opts.separator ''
opts.separator ""
opts.on('-p', '--port=port', Integer,
'Runs Instiki on the specified port.',
'Default: 2500') { |OPTIONS[:port]| }
opts.on('-b', '--binding=ip', String,
'Binds Rails to the specified ip.',
'Default: 0.0.0.0') { |OPTIONS[:ip]| }
opts.on('-e', '--environment=name', String,
'Specifies the environment to run this server under (test/development/production).',
'Default: production') { |OPTIONS[:environment]| }
opts.on('-d', '--daemon',
'Make Instiki run as a Daemon (only works if fork is available -- meaning on *nix).'
opts.on("-p", "--port=port", Integer,
"Runs Rails on the specified port.",
"Default: 3000") { |OPTIONS[:port]| }
opts.on("-b", "--binding=ip", String,
"Binds Rails to the specified ip.",
"Default: 0.0.0.0") { |OPTIONS[:ip]| }
opts.on("-e", "--environment=name", String,
"Specifies the environment to run this server under (test/development/production).",
"Default: development") { |OPTIONS[:environment]| }
opts.on("-d", "--daemon",
"Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)."
) { OPTIONS[:server_type] = WEBrick::Daemon }
opts.on('-s', '--simple', '--simple-server',
'[deprecated] Forces Instiki not to run as a Daemon if fork is available.',
'Since version 0.10.0 this option is ignored.'
) { puts "Warning: -s (--simple) option is deprecated. See instiki --help for details." }
opts.on('-t', '--storage=storage', String,
'Makes Instiki use the specified directory for storage.',
'Default: ./storage/[port]') { |OPTIONS[:storage]| }
opts.on('-x', '--notex',
'Blocks wiki exports to TeX and PDF, even when pdflatex is available.'
) { |OPTIONS[:notex]| }
opts.on('-v', '--verbose',
'Enables debug-level logging'
) { OPTIONS[:verbose] = true }
opts.separator ''
opts.separator ""
opts.on('-h', '--help',
'Show this help message.') { puts opts; exit }
opts.on("-h", "--help",
"Show this help message.") { puts opts; exit }
opts.parse!
end
if OPTIONS[:environment] == 'production'
storage_path = "#{OPTIONS[:storage]}/#{OPTIONS[:port]}"
else
storage_path = "#{OPTIONS[:storage]}/#{OPTIONS[:environment]}/#{OPTIONS[:port]}"
end
FileUtils.mkdir_p(storage_path)
ENV["RAILS_ENV"] = OPTIONS[:environment]
require File.dirname(__FILE__) + "/../config/environment"
require 'webrick_server'
ENV['RAILS_ENV'] = OPTIONS[:environment]
$instiki_debug_logging = OPTIONS[:verbose]
require File.expand_path(File.dirname(__FILE__) + '/../config/environment')
WikiService.storage_path = storage_path
OPTIONS['working_directory'] = File.expand_path(RAILS_ROOT)
if OPTIONS[:notex]
OPTIONS[:pdflatex] = false
else
begin
OPTIONS[:pdflatex] = system "pdflatex -version"
rescue Errno::ENOENT
OPTIONS[:pdflatex] = false
end
end
if defined? INSTIKI_BATCH_JOB
require 'application'
else
puts "=> Starting Instiki on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
puts "=> Data files are stored in #{storage_path}"
require 'webrick_server'
require_dependency 'application'
OPTIONS[:index_controller] = 'wiki'
ApplicationController.wiki = WikiService.instance
DispatchServlet.dispatch(OPTIONS)
end
puts "=> Rails application started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
puts "=> Ctrl-C to shutdown server; call with --help for options" if OPTIONS[:server_type] == WEBrick::SimpleServer
DispatchServlet.dispatch(OPTIONS)