jlong / serve

Serve is a small Rack-based web server and rapid prototyping framework for Web applications (specifically Rails apps). Serve is meant to be a lightweight version of the Views part of the Rails MVC. This makes Serve an ideal framework for prototyping Rails applications or creating simple websites. Serve has full support for Rails-style partials and layouts.
http://get-serve.com
Other
836 stars 90 forks source link

Can't start serve on a different port #49

Open joevandyk opened 13 years ago

joevandyk commented 13 years ago
$ serve 2100
[2011-09-05 13:43:36] INFO  WEBrick 1.3.1
[2011-09-05 13:43:36] INFO  ruby 1.9.2 (2011-07-09) [x86_64-darwin11.1.0]
[2011-09-05 13:43:36] INFO  WEBrick::HTTPServer#start: pid=40613 port=4000

It's running on port 4000, I'd expect it to use port 2100.

joevandyk commented 13 years ago

Bah, figured it out.

I had to remove this line from the generated config.ru:

#\ -p 4000
joevandyk commented 13 years ago

Is there a reason why that line is there?

jlong commented 13 years ago

In this case Serve is just delegating to the rackup command. You need to edit your config.ru. The very first line tells it which port to start.

John Long http://wiseheartdesign.com

On Sep 5, 2011, at 4:47 PM, joevandykreply@reply.github.com wrote:

$ serve 2100 [2011-09-05 13:43:36] INFO WEBrick 1.3.1 [2011-09-05 13:43:36] INFO ruby 1.9.2 (2011-07-09) [x86_64-darwin11.1.0] [2011-09-05 13:43:36] INFO WEBrick::HTTPServer#start: pid=40613 port=4000 ^C[2011-09-05 13:43:38] INFO going to shutdown ... [2011-09-05 13:43:38] INFO WEBrick::HTTPServer#start done.

Reply to this email directly or view it on GitHub: https://github.com/jlong/serve/issues/49

joevandyk commented 13 years ago

Right, but why is is this line here?

https://github.com/jlong/serve/blob/master/lib/serve/bootstrap/config.ru#L1

Everyone who wants to run serve on a different port will need to know to remove that line if they want to follow the documentation in the README.

jlong commented 13 years ago

Well, the assumption here is that if you have a project with a config.ru in it that you know which port you want it to run on, so if you want to change it, you'd change it in the config.ru. But perhaps the -p option should override as you suggest. In fact, I'm leaning that way now that you've talked me through it.

This month is kind of busy for me so I don't have a lot of time to work on Serve, but I'd merge a pull request if you send one my way. It's probably just a matter of making sure the port is handed over to the rackup command in the Application object.

Otherwise, it'll be a bit before I get to it.

--John

On Sep 6, 2011, at 12:29 AM, joevandyk wrote:

Right, but why is is this line here?

https://github.com/jlong/serve/blob/master/lib/serve/bootstrap/config.ru#L1

Everyone who wants to run serve on a different port will need to know to remove that line if they want to follow the documentation in the README.

Reply to this email directly or view it on GitHub: https://github.com/jlong/serve/issues/49#issuecomment-2008785

pbyrne commented 13 years ago

This looks like it might be in the rackup command itself. You're passing the user-supplied port in Serve::Application#run_rack_app, and trying rackup -p 2100 -o 0.0.0.0 -E development './config.ru' in the command line exhibits the behavior of using the port from config.ru rather than from the -p argument.

$ rackup -p 2100 -o 0.0.0.0 -E development './config.ru'
[2011-09-12 19:39:13] INFO  WEBrick 1.3.1
[2011-09-12 19:39:13] INFO  ruby 1.9.2 (2011-07-09) [x86_64-darwin10.8.0]
[2011-09-12 19:39:13] INFO  WEBrick::HTTPServer#start: pid=9125 port=4000
hedgehog commented 12 years ago

Even when I change #\ 4100 and run bundle exec serve I see:

$> ps aux|grep -i rackup
hedge    19696  6.4  0.2 128644 47228 pts/30   Sl   19:59   0:08 ruby /src/proj/vendor/ruby/1.9.1/bin/rackup -p 3000 │Using /home/hedge/.rvm/gems/ruby-1.9.2-p290 with gem-o 0.0.0.0 -E development ./config.ru
ntalbott commented 12 years ago

So what's the verdict? Should we remove the port from the config.ru? Honestly it seems really strange to me to have it hardcoded in there.

jlong commented 12 years ago

Yes. I still want the rails_app? checks in there though. That stuff should be updated for Rails 3 though. The idea is that serve can be used to start any rack or rails app, too.