Trying to test django app locally with foreman - django

I'm working on a django app and trying to use foreman to test my app locally before pushing to heroku. I can successfully run it using python manage.py server. However when running it using forman it fails - Whenever I do a foreman start inside of the directory it would return me this:
09:21:09 web.1 | started with pid 9956
09:21:09 web.1 | /usr/local/foreman/bin/foreman-runner: line 41: exec: gunicorn: not found
09:21:09 web.1 | exited with code 127
09:21:09 system | sending SIGTERM to all processes
SIGTERM received
What does this mean?
Below is my Procfile:
web: gunicorn myapp.wsgi
Below is my requirements.txt
Django==1.4.3
distribute==0.6.31
dj-database-url==0.2.1
psycopg2==2.4.6
#wsgiref==0.1.2
gunicorn==0.16.1
Thanks for the help in advance!

It looks like gunicorn isn't installed properly on your system.
Run pip install -r requirements.txt and then manually run the gunicorn command to check it works.

I came to this question with the same problem finding gunicorn when running 'foreman start', but eventually dug up at other sources that I was not recreating the virtualenv in a new bash session. I had originally followed the instructions from Heroku, but days later with new sessions, needed to remember to run
source venv/bin/activate

Had the issue - installing separately gunicorn did the trick
pip install gunicorn

I had the same issue:
sudo apt-get install libpq-dev python-dev
and then reinstalling the heroku-toolbelt solved it!

Related

What is the propper way to debug gunicorn?

I am trying to deploy my very first Django applicatin on heroku. Gunicorn gives me this error: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
In this answer https://stackoverflow.com/a/55623889 command gunicorn app:application --preload -b 0.0.0.0:5000 is said to give detailed error message, but as its comments state it is not clear what words to replace with what. For instance somewhere I saw something similar called with <name of my app>.wsgi. To make matter worse name of my Django app in local is different from the one on Heroku.
Also it is not clear to me should this be called strait from terminal (within virtual env) or should I be using some sort of gunicorn CLI.
So what is the actual propper way to figure out what is failing gunicorn?
I've faced similar issues in the past. I hope this might help:
Make sure gunicorn is installed in your activated virtual environment project by running pip freeze in the terminal to verify it's installation. If it is not listed, in the activated virtual environment, run pip install gunicorn or else if you are using pipenv, run pipenv install gunicorn. Don't forget to update the requirements.txt file by running pip freeze > requirements.txt
In the Procfile which is within the project_directory type the syntax:
web: gunicorn your_django_project_name.wsgi --log-file -
N.B: There should be a space between;
The --log-file and the - next to it.
web: and the gunicorn part of the code.
Finally add, commit and push the changes to the heroku server.

Gunicorn not working on Amazon ec2 server

I am trying to deploy a django website on an aws ec2 instance (ubuntu 18.04) following this tutorial that is consistent with other online resources. Everything is working fine but there is some issue with gunicorn. The worker doesn't seem to boot.
I figured there was something wrong with my installation and I tried uninstalling and installing with different commands-
inisde my virtualenv with
pip install gunicorn
and
sudo -H pip install gunicorn
I even physically deleted all gunicorn files and reinstalled gunicorn but its always the same. Where have I gone wrong?
p.s: I had initially done sudo apt-get
From the screenshot you attached, it seems that gunicorn is installed correctly, but perhaps you have not passed a configuration file. The command to run gunicorn with a configuration is
gunicorn -c /path/to/gunicorn.conf.py myapp.wsgi:application

gunicorn not found on heroku

I want to deploy a very basic Django app on Heroku. I followed the instructions, but the browser shows me the Heroku error page and the heroku logs say
bash: gunicorn: command not found
I have gunicorn in my requirements.txt and configured the wsgi.py and Procfile as instructed by the documentation. What else can I try?
Edit: I also tried to install gunicorn manually on Heroku (heroku run pip install gunicorn), which worked fine, so I am pretty sure that gunicorn is installed. Why doesn't Heroku find it?
Edit 2: It seems that I can install gunicorn manually (heroku run bash and then pip install gunicorn:
~ $ gunicorn
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: No application module specified.
but when i log out and log in to the bash again, i get:
~ $ gunicorn
bash: gunicorn: command not found
Heroku seems to install but then discard gunicorn. How can that be?
Hi got the same problem but this might help:
Go to this:
https://github.com/heroku/heroku-buildpack-python
And try to run this command in project's root terminal:
heroku buildpacks:set git://github.com/heroku/heroku-buildpack-python.git
and then update heroku with running below command:
git push heroku master

Foreman start only has one line for Django and heroku

I install the heroku toolbelt from the website and use pip to install django toolbelt on both mac and ubuntu vm copy.
Both of them only return one line when using foreman start:
Procfile:
web: gunicorn hero.wsgi
foreman start:
23:44:46 web.1 | started with pid 4382
Ctrl+C and I got:
23:47:36 system | sending SIGTERM to all processes
23:47:36 web.1 | terminated by SIGTERM
I have read about the https://github.com/ddollar/foreman/wiki/Missing-Output
and did:
script.py:
PYTHONUNBUFFERED=True
and run it with python -u script.py
What am I doing wrong? Any advice will be appreciated.

Cannot install gunicorn on Ubuntu

I'm trying to install gunicorn in my virtual env, but get the following:
$ pip install gunicorn
Downloading/unpacking gunicorn
Downloading gunicorn-0.14.2.tar.gz (203Kb): 203Kb downloaded
Running setup.py egg_info for package gunicorn
warning: no files found matching '*' under directory 'debian'
Installing collected packages: gunicorn Found existing installation: gunicorn 0.14.2
Uninstalling gunicorn:
Successfully uninstalled gunicorn
Running setup.py install for gunicorn
warning: no files found matching '*' under directory 'debian'
Installing gunicorn_paster script to /home/aemdy/Documents/projects/reborn/env/bin
Installing gunicorn script to /home/aemdy/Documents/projects/reborn/env/bin
Installing gunicorn_django script to /home/aemdy/Documents/projects/reborn/env/bin
Successfully installed gunicorn
Cleaning up...
And when I use python manage.py run_gunicorn for django it says that this is unknown command. I have added gunicorn to INSTALLED_APPS.
Warnings like that appear sometimes when installing apps. I believe it's related to cleanup pip tries to do, but it doesn't matter regardless. As the console output says "Successfully installed gunicorn". So no problems there.
With gunicorn installed, the only other requirement is adding gunicorn to INSTALLED_APPS. If you've done that as well, you're done. run_gunicorn will be available.
So, if it's not working, one of the following is in play:
Gunicorn isn't actually installed. However, you should get an error trying to reference in in INSTALLED_APPS in that scenario. Check your virtualenv's site-packages directory to ensure there's gunicorn folder there.
You installed Gunicorn in a different virtualenv. Again, you should be getting an error just as in #1. And, just as in #1, check to make sure it's actually in the proper virtualenv's site-packages directory
You don't have the virtualenv activated. However, same error as in #1 and #2 applies here.
You really don't have gunicorn in INSTALLED_APPS or a compiled version of settings.py is being used that doesn't have it in INSTALLED_APPS. Delete settings.pyc if it exists.
I just ran into this issue. What I did was try to run the app using runserver which led to me seeing the hostname on the server was not set(and thus can't get an IP address). Once we fixed that issue the command worked again.
It is a little misleading to see:
Unknown command: 'run_gunicorn'
Type 'manage.py help' for usage.
when the hostname is not set...confusing I know but I hope this helps someone in the future.
Did you remember to add gunicorn to your INSTALLED_APPS?