I use Rchilli resume parser for parsing resume. It works fine while running on python manage.py runserver . I am getting an xml data as api response. But while running on gunicorn I'm getting an html response saying that "The service is temporarily unavailable". Is there something need to be changed on the configuration of gunicorn to get this fixed? As the project is still under development, I'm using only gunicorn for deploying the application. I am using this Method:Lessons Learned From The Dash: Easy Django Deployment for deploying the application without nginx.
Related
I created a simple flask application that needs authentication to have access to the data.
When I run this application locally it works fine (accepts more than one client), however when I host the app on railway or heroku it can't handle more than one client.
Ex: when I access the URL on a computer and log in, if I access the URL on my cellphone (different netowrk) I get to have access to that account logged in.
I'm using the latest version of flask and using flask_login to manage authentication.
Does anyone have any idea why it's happening?
I've tried everything I found out on Internet, such as using
app.run(threaded=True)
I've also set the numbers of workers on gunicorn command for exemple
Does anyone have any idea why it's happening?
As official Flask's documentation says, never run your application in production in dev mode (what app.run() actually is).
Please refer to this section if you are going to deploy in self-hosted machine: https://flask.palletsprojects.com/en/2.2.x/deploying/
And if you are going to deploy to Heroku, you need to prepare for correct Procfile, like this:
web: gunicorn run:app
I've just solved it.
My gunicorn was in sync way and would handle only one request at a time.
So I had insert threads number on Procifle in order to it change worker_class from sync to Gthread
My Procfile afterall:
web: gunicorn --threads 4 :$PORT index:app
https://docs.gunicorn.org/en/stable/design.html#choosing-a-worker-type
I am building a back end in python via the python flask application from IBM Cloud/Bluemix. I have heard/read a lot about people complaining regarding that Flasks built in server isn’t good for production. But how do I know if the application uses the Flask built in server or if IBM sets something else? Is there a simple way to see this in the code?
Deploying the Flask boilerplate app from the IBM cloud catalogue will indeed deploy a Flask application running on the Flask dev webserver.
You will need to alter the application if you want to run a production WSGI server.
I work for IBM and am in this stuff all day every day.
If you want to verify this, SSH into your application container on Cloud Foundry with the bash command
cf ssh <yourappnamehere>
You will need to have either the bluemix or cloud foundry CLIs installed and be logged in to the relevant endpoint before submitting this command.
It will open a bash shell in your application container, and you can cd around and open and/or download your project files for inspection.
This line:
app = Flask(__name__)
is a sure fire way to know that you are running a Flask web server application.
If you are concerned with which WSGI server your application is running under, checking your procfile (you should see this when SSHing int your container) will show you which command starts your application. If the command is
python <yourapp>.py
then you are running the dev server. Otherwise, you would be running some other python file, most likely via the server's command rather than the python command, that would import your application as a dependency.
You can also take a look at whether or not any WSGI server libraries were downloaded during the compilation of your droplet, and what command was used to start your application with
cf logs <yourappname> --recent
after deploying it.
Or, you can just believe me that the boilerplate deploys a Flask app under a Flask dev server.
A tutorial on running Flask on a different WSGI server:
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04
For running django applications locally I can do
django-admin startproject djangotest
python djangotest/manage.py runserver
and the sample webpage shows up at http://127.0.0.1:8000/
However, when I deploy this to EB with
eb deploy
It just magically works. My question is does EB runs the command python djangotest/manage.py runserver on the EC2 server after eb deploy by default? What are the list of commands that EB executes to get the webpage working? What if I want it to run with different flags like python djangotest/manage.py runserver --nostatic is that possible?
It doesn't just magically work. You have to configure Django for Elastic Beanstalk, as described in the EB documentation: you provide a configuration file which points to the WSGI module.
In any case, it wouldn't use runserver, as the development server is absolutely not for production use.
I want to use twitter streaming API.
https://github.com/michaelbrooks/django-twitter-stream
This plugin work exactly how I want and it is using tweepy library of python for same.
To run this code its expecting to run via command line i.e.
./manage.py stream
Its good to test the same in my local.
But I am not getting how to deploy the same in my aws through server where my remaining django project is already getting served via apache server
I am not pretty sure whether some sort of CRON or celery can be used in scenario.
I've downloaded google_appengine version 1.3.1. Using some web tutorials, I've created basic django 1.1.1 application. Using appcfg I managed to deploy it on GAE and it works. The problem is, that application doesn't want to work on dev_appengine.py developement server.
Whenever I run the app GAE local server is returning HTTP 200 without any content. If I set basic environement and run main.py manually, then the page is properly returned on stdout.
I've also created very basic helloworld application, and this one is working ok on the devel server.
Do you have any idea, how can I debug the devel server? Option -d doesn't give any usefull insight at all.
I had module nammed same way as the default GAE launcher (main/ and main.py). After renaming the launcher everything works great.