Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Support for rackup or config.ru Rack application? #8

Closed
boazsegev opened this issue Mar 25, 2018 · 10 comments
Closed

CLI Support for rackup or config.ru Rack application? #8

boazsegev opened this issue Mar 25, 2018 · 10 comments

Comments

@boazsegev
Copy link

HI,

I was wondering if there's any way to run Rack applications from the command line interface (CLI)?

The default Rack application file is config.ru and it might contain anything from a Rails application to a simple Hello World (example config.ru file):

out = [200, {"Content-Length" => "12"}, ["Welcome Home"] ].freeze
app = Proc.new { out }
run app

These can be executed using the rackup command using Puma, iodine, Thin, etc' by adding the -s flag.

Could agoo be added to this?

I'd love to be able to run Rails, Sinatra or any other application using:

$ rackup -s agoo

The downside is that rackup sometimes automatically adds middleware to the application (in development mode), so I'd be slightly happier if the CLI itself could run the config.ru app... This way, the Rack application could be executed without any surprises when agoo is called in the same folder as the app. i.e.:

$ agoo -p 3000

I know this will break backwards compatibility for the CLI, but using rackup should be possible without breaking backwards compatibility, shouldn't it?

@ohler55
Copy link
Owner

ohler55 commented Mar 25, 2018

rackup -S agoo should work right now but since rack does not name agoo in the like require agoo is needed to allow that.

@boazsegev
Copy link
Author

I tried rackup -p 3000 -s agoo -r agoo which failed.

Using a capital -S doesn't seem to solve it (I get "invalid option").

iodine works with rackup...

Perhaps it has to do with this folder structure or this line... I can't remember what finally worked, but something did, I think maybe both were required.

@boazsegev
Copy link
Author

I got it to work with a capital A in Agoo...

$ RACK_ENV=production rackup -p 3000 -r agoo -s Agoo

IMHO, CLI integration could be improved, but the important part is that I got it running.

Thanks!

@ohler55
Copy link
Owner

ohler55 commented Mar 25, 2018

I need more feedback to improve. Your feedback helps. Am typing from a phone so the -s was autocorrected. I remember now about capital A in Agoo. Rack expected that as the case sensitive module or class name.

@boazsegev
Copy link
Author

Rack expected that as the case sensitive module or class name.

Maybe register two names ;-)

@ohler55
Copy link
Owner

ohler55 commented Mar 25, 2018 via email

@boazsegev
Copy link
Author

This might help:

::Rack::Handler.register('agoo', 'Rack::Handler::Agoo') if defined?(::Rack::Handler)

@ohler55
Copy link
Owner

ohler55 commented Mar 25, 2018 via email

@ohler55
Copy link
Owner

ohler55 commented Mar 27, 2018

The 1.2.2 release should allow lower case agoo to be used.

@ohler55
Copy link
Owner

ohler55 commented May 1, 2018

All working. Closing.

@ohler55 ohler55 closed this as completed May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants