DoSomething / lofi-schools-flask

Flask implementation of the school search service
MIT License
0 stars 2 forks source link

Broken. #4

Closed DFurnes closed 8 years ago

DFurnes commented 8 years ago

This app is currently broken. :cry:

I'll keep a log of troubleshooting it in this issue.

/cc @mikefantini

DFurnes commented 8 years ago

So the Heroku app is running, but we are querying it over HTTP on staging (since staging used to be HTTP before we started routing it through Fastly). This is causing the request to be blocked since it's trying to make an insecure request from a secure page. I switched the API endpoint in DoSomething User settings to https://lofischools.herokuapp.com/search and that fixed that issue.

DFurnes commented 8 years ago

Next issue… again likely related to changing the domain for staging:

XMLHttpRequest cannot load https://lofischools.herokuapp.com/search?state=CT&query=m&limit=10. Origin https://staging.dosomething.org is not allowed by Access-Control-Allow-Origin.`
DFurnes commented 8 years ago

Well, maybe not – @blisteringherb set the CORS header to * in #1 (which is merged into master on Heroku, even though it's not merged on Github):

app.config['CORS_RESOURCES'] = {r"/search*": {"origins": "*"}}
DFurnes commented 8 years ago

Oh, looking at it directly though – the endpoint https://lofischools.herokuapp.com/search?state=CT&query=m&limit=10 is actually returning an application error though so that could explain why the CORS headers aren't being applied:

screen shot 2015-11-12 at 2 43 27 pm

And from the Heroku application logs:

2015-11-12T19:46:04.469945+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/search?state=CT&query=m&limit=10" host=lofischools.herokuapp.com request_id=e4a679dc-39a4-45e7-b55d-3ecdf1d18f72 fwd="207.110.19.130" dyno= connect= service= status=503 bytes=

...not terribly helpful, as far as error messages go.

DFurnes commented 8 years ago

I'm not 100% sure this is accurate, but I tried logging into our MongoLab account where the database for this is supposedly hosted (going by code & environment variables on Heroku) and it shows that there are no databases set up on that account. If so, that'd merit a crash...

weerd commented 8 years ago

@_@

DFurnes commented 8 years ago

I get a "connection refused" when trying to connect to the database from my local CLI using the credentials stored in the Heroku environment variables. I'm not sure if this is because they're only allowing connections from Heroku... or just that it doesn't exist.

DFurnes commented 8 years ago

Hmm, not looking good. I tried making a test "sandbox" database on MongoLab and I can connect to it fine from my local machine, so my guess is that the database that had all the school information no longer exists. :wave:

mikefantini commented 8 years ago

@mshmsh5000 (for when you're back on Monday) do you know if we have any backup or any other insights into what might be going on here?

mshmsh5000 commented 8 years ago

I did a heroku restart in one shell and a heroku logs -t in another. This was significant:

2015-11-13T01:53:23.601008+00:00 heroku[web.1]: Starting process with command `gunicorn --pythonpath lofi main:app`
2015-11-13T01:53:25.724035+00:00 app[web.1]: bash: gunicorn: command not found

Needed to add gunicorn to requirements.txt. I didn't look to see what has changed, but I presume it's something in Heroku's build procedure for Python apps or pip package handling. This app does use the Heroku Python Buildpack, which is supposed to take care of these niggling details, but in this case it didn't (possibly because we explicitly include our own requirements.txt, which the buildpack is meant to construct dynamically).

We're processing requests again. Feel free to close unless you find yet another issue.

DFurnes commented 8 years ago

Not sure what I was doing wrong with connecting to the database, but it obviously exists somewhere. Going to close this since everything seems good on staging now. Sorry to bother you while you're out, @mshmsh5000!