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

Development 404 page still shows up when using -e production command-line flag #1544

Closed
leafac opened this issue Jun 22, 2019 · 5 comments · Fixed by #1547
Closed

Development 404 page still shows up when using -e production command-line flag #1544

leafac opened this issue Jun 22, 2019 · 5 comments · Fixed by #1547

Comments

@leafac
Copy link

leafac commented Jun 22, 2019

Let server.rb be simply

require "sinatra"

Now run it with

$ ruby server.rb -e production

Sinatra will say that it’s running in production mode:

== Sinatra (v2.0.5) has taken the stage on 4567 for production with backup from Thin

But visit http://localhost:4567 and you’ll see the development 404 page:

Screen Shot 2019-06-22 at 08 35 48

I tried this with both WEBrick and Thin.

Of course, the problem goes away when using the APP_ENV environment variable:

$ env APP_ENV=production ruby server.rb

Screen Shot 2019-06-22 at 08 37 23

@jkowens
Copy link
Member

jkowens commented Jul 4, 2019

This is an interesting issue. It happens because this block is called before the command line options are parsed and handled:

configure :development do

Command line options are processed later here:

if run? && ARGV.any?

@leafac
Copy link
Author

leafac commented Jul 5, 2019

How do you think this problem should be solved?

@jkowens
Copy link
Member

jkowens commented Jul 5, 2019

Good question, I tried a couple options and realized it isn’t as easy to fix as I hoped. The issue is that classical apps extend Application which extends Base (where the configurations are originally made). So supporting both classic and modular style apps becomes tricky. If anyone has any ideas please chime in 🙂

@leafac
Copy link
Author

leafac commented Jul 6, 2019

Hmmm, what if we didn’t offer the command-line flag? It’s awkward that we have two ways of accomplishing the same thing, and it’s difficult to tell which should be preferred (the environment variable, it seems).

@jkowens
Copy link
Member

jkowens commented Jul 7, 2019

That sounds like a valid option to me. I put together a PR #1547 for another possible solution.

namusyaka added a commit that referenced this issue Aug 17, 2019
Fix issue setting environment from command line option
Fixes #1544
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

Successfully merging a pull request may close this issue.

2 participants