Script/server script


#1

Hi all,

I’m new to rails (and ruby) so bear with me.

I’ve analysed script/server (and subsequent scripts) and as far as I
can tell, the actions performed in a newly created rails app (on my
GNU/Linux box running lighttpd) when

$ script/server lighttpd

is called, can be summarised thus (ignoring the ‘requires’):

RAILS_ROOT = '/home/<your_home>/rails/<your_app>'

Rails::Initializer.run(:set_load_path)

FileUtils.mkdir_p(%w( tmp/sessions tmp/cache tmp/sockets ))

server = 'lighttpd'
configuration = 

Rails::Initializer.run(:initialize_logger).configuration
detach = false
config_file = “#{RAILS_ROOT}/config/lighttpd.conf’
config = IO.read(config_file)
default_port, default_ip = 3000, ‘0.0.0.0’
port = config.scan(/^\sserver.port\s=\s*(\d+)/).first rescue
default_port
ip = config.scan(/^\sserver.bind\s=\s*”([^"]+)"/).first rescue
default_ip

puts "=> Rails application started on http://#{ip || 

default_ip}:#{port || default_port}"

Having saved some ‘state’ in these local variables, it then ‘rakes’
the tmp/sockets directory and fires up lighttpd.

My question is why save this state in the local variables? How is
this information useful, and to what processes?

Any help much appreciated.

Sebastian


#2

Sebastian,

I’m fairly new here too, but my impression is that questions like
these (design/architecture questions) are better directed to the
rails-core list. I think this list is more for usage questions.

Gordon


#3

I agree with Gordon… mostly because this is a user list, and I don’'t
think many of the rails core members read the list on a regular basis,
so your point, as valid as it could be, would go unnoticed by the core
members Seb.

Cheers.