Can't find web process procfile error with Windows Heroku - python

I want to deploy my website which works locally, but runs an error when it tries to have a public instance.
I am on Windows 8.1 and following the official instructions have created a Procfile.windows. It looks like this:
web: python app.py runserver 0.0.0.0:5000
The build works, but then I get this error when I run heroku ps:scale web=1:
Couldn't find that process type (web).
Repo here.
The official tutorial works, so there's definitely proof of concept of this working somehow.

I am on Windows 8.1 and following the official instructions have created a Procfile.windows
Why did you name this file Procfile.windows? The documentation is quite clear:
The Procfile is always a simple text file that is named Procfile without a file extension. For example, Procfile.txt is not valid.
Rename it to Procfile and redeploy.
Once you've got that working, install a WSGI server and use that instead of manage.py runserver, which isn't suitable for production use:
DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)
Gunicorn is probably the most common choice, but I don't think it works on Windows so you won't be able to use it in your development environment. uWSGI or Waitress should work.

I installed Waitress and changed my Procfile to
web: waitress-serve --port=$PORT app:app
I also removed the .windows extension, which is meant for local development.
It works fine now!
(My equivalent to "main.py" was "app.py" so you'd likely change this for your needs to {main.py}:app)

Edit your procfile to look like
web: gunicorn --bind 0.0.0.0:$PORT app:app
And your procfile.windows filed as
web: python app.py runserver 0.0.0.0:5000

Related

Deploying Python FastAPI to AWS Beanstalk

I have a small python FastAPI project which is completely working on my local computer. But when I try to deploy it to AWS Beanstalk (manually for now) I've always got a '502 Bad Gateway' error when open the application in a browser.
This is my project structure:
/project
/html/
main.py
Procfile
requirements.txt
the main.py contains the api endpoints that use some HTML files. These files are in the html/ folder.
The Procfile looks like this:
web: uvicorn main:app --host 0.0.0.0 --port 80
and the requirements.txt like this:
fastapi~=0.91.0
uvicorn
When I uploaded an example application from AWS to the same Beanstalk environment, it worked. And as I said, even if I execute the python project locally, it works fine. So I must have configured something wrong.
Does anybody know this problem and know how to fix it?
Found this useful guide that solved my problem: https://testdriven.io/blog/fastapi-elastic-beanstalk/.
Maybe there is someone who needs it.

Can't connect to django website started on VPS

I have tried to start server with Django project like this:
python3.4 manage.py runserver 0.0.0.0:8000
and like this:
python3.4 manage.py runserver my_domain.com:8000
and it starts fine but I can't visit my site. Any ideas what I've done wrong?
The command python manage.py runserver is thought for development purposes.
If you have in mind to have a python (django in this case) website running in a remote server, try having a look at uwsgi.
It's an application server that plays really well with nginx.
Then, it could be possible run your site using the wsgi file in your django project:
uwsgi --http :8000 --module mysite.wsgi
In order to configure your django site, follow this documentation.
Also, if you plan to host more than one website, uwsgi has a emperor mode with slightly different configuration, but really worth for your VPS memory.

Django app on Heroku, deployed successfully but could not be served

I have built a simple blog app with Django by following a video and deployed it to Heroku by following another video.
The app works fine locally, but it is not working online.
Heroku gives me this error message:
This app has no process types yet
Add a Procfile to your app in order to define its process types.
I had already added a Proclife created with Notepad with these contents:
web: gunicorn mysite.wsgi
But how can I add another Procfile to an app already deployed to Heroku?
Where should I place it?
Yeah that's correct. It required file 'Procfile' in the project root directory. I have created one with below content
web: gunicorn <your-app.wsgi> -b 0.0.0.0:$PORT -w 10
And followed the below link https://devcenter.heroku.com/articles/procfile where everything is mentioned to deploy the code to heroku.
Its been long time for me working with heroku that too with test app so I am not sure if it got changed after that. But I think just following the link will work just fine.

How can I get a live reload like GAE with FALCON?

I am setting up a new project that is going to use python to build a RESTful back end. I looked at GAE, but choose Falcon Framework, because the application needs to eventually be installed on local servers. GAE has a great development feature, it allows for iterative development by watching the source, and reloading.
You can leave the web server running while you develop your
application. The web server knows to watch for changes in your source
files and reload them if necessary.
How can I set up Falcon to do the same thing?
This may not be the best answer, but I found that there is no simple method that does not require more software installed the way GAE does it, but after you install gunicorn, your can use the --reload switch and the server will auto-reload the source.
$ gunicorn -b 127.0.0.1:8000 -b [::1]:8000 --reload myapp:app
Docs: http://docs.gunicorn.org/en/19.0/settings.html#reload
Auto-reloading is not a feature of the framework (Falcon), but rather of the server. If you do want auto-reloading, the simplest way to do it is run your Falcon code on a gunicorn server, using the --reload switch. For example:
$ gunicorn --reload app:app
Assuming your API is inside app.py and named app.

Does Gunicorn run on Windows

I have looked around for a while, and I was surprised not finding any information whether Gunicorn runs on Windows or not.
Does anyone know if that is the case, and if so, where can I find some documentation about it?
Technically this is not an answer. But practically the answer I was looking for is how to run a WSGI web app (like Django) on Windows, and for those who got into this page because of that, here it is:
I'm using waitress now, very good alternative :)
Basically all you have to do is replace the gunicorn call with:
waitress-serve --listen=*:8000 myapp.wsgi:application
For typical apps this will give you the same result as running gunicorn. :) Good luck!
Gunicorn is for a UNIX environment and is incompatible with Windows.
Also for more info please refer to it's docs.
Edit: there's now a plan to add Windows support. https://github.com/benoitc/gunicorn/issues/524
No. Gunicorn doesn't run on Windows. It's very design is to take 'advantage of features in Unix/Unix-like kernels'.
gunicorn used not to run directly on Windows, but work (and pending issues being resolved) mean that you can make it work on Cygwin.
See https://github.com/benoitc/gunicorn/issues/407 ....
(Note: I update this answer because the bug has now been fixed)
Gunicorn does not support windows, although you can use waitress
I'm trying to Build ASGI app on windows using FASTAPI. FASTAPI is run on Gunicorn & Uvicorn server.I read the FASTAPI documentation to find out how to deploy my app on windows. They suggesting to use docker to deploy the app from windows. It turns out to be the best way to use Gunicorn on windows.
On Windows, you can install guvicorn like that:
pip install uvicorn gunicorn
And then, run your server using the notation available in https://www.uvicorn.org/. Example:
uvicorn myproject.asgi:application --host 127.0.0.1 --port 80 --reload
It's how I use in production and it's being consistent to serve my Django ASGI applications.

Categories

Resources