So I am trying to follow this here:
except on the latest raspberry pi. I think or thought I had everything configured correctly...
In that tutorial above it gets you from creating a django project to getting it to run under gunicorn and even testing that with:
activating the virtual env and then
cd ~/myproject
gunicorn --bind 0.0.0.0:8000 myproject.wsgi
That part works, once that comes up it is like i did a python3 manage.py runserver 0.0.0.0:8000
i can Then goto my browser and type in the host name:
webserver2.abc.com:8000
and that all works app comes up.
If I stop the gunicorn command and type deactivate then I try to run it using the .service I added in /etc/systemd/system. It seems to run and a
sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2020-10-21 13:24:51 MDT; 50s ago
Main PID: 7645 (gunicorn)
Tasks: 4 (limit: 4915)
Memory: 55.0M
CGroup: /system.slice/gunicorn.service
├─7645 /home/pi/myvirtualenv_covid19/covid19env/bin/python /home/pi/myvirtualenv_covid19/covid19env/bin/gunicorn --workers 3 --bind unix:/tmp/covid19.sock covid19.wsgi:application
├─7651 /home/pi/myvirtualenv_covid19/covid19env/bin/python /home/pi/myvirtualenv_covid19/covid19env/bin/gunicorn --workers 3 --bind unix:/tmp/covid19.sock covid19.wsgi:application
├─7652 /home/pi/myvirtualenv_covid19/covid19env/bin/python /home/pi/myvirtualenv_covid19/covid19env/bin/gunicorn --workers 3 --bind unix:/tmp/covid19.sock covid19.wsgi:application
└─7653 /home/pi/myvirtualenv_covid19/covid19env/bin/python /home/pi/myvirtualenv_covid19/covid19env/bin/gunicorn --workers 3 --bind unix:/tmp/covid19.sock covid19.wsgi:application
Oct 21 13:24:51 webserver2 systemd[1]: Started gunicorn daemon.
Oct 21 13:24:51 webserver2 gunicorn[7645]: [2020-10-21 13:24:51 -0600] [7645] [INFO] Starting gunicorn 20.0.4
Oct 21 13:24:51 webserver2 gunicorn[7645]: [2020-10-21 13:24:51 -0600] [7645] [INFO] Listening at: unix:/run/gunicorn.sock (7645)
Oct 21 13:24:51 webserver2 gunicorn[7645]: [2020-10-21 13:24:51 -0600] [7645] [INFO] Using worker: sync
Oct 21 13:24:51 webserver2 gunicorn[7645]: [2020-10-21 13:24:51 -0600] [7651] [INFO] Booting worker with pid: 7651
Oct 21 13:24:51 webserver2 gunicorn[7645]: [2020-10-21 13:24:51 -0600] [7652] [INFO] Booting worker with pid: 7652
Oct 21 13:24:51 webserver2 gunicorn[7645]: [2020-10-21 13:24:51 -0600] [7653] [INFO] Booting worker with pid: 7653
To confirm.
So it seems to be running, though going to webserver2.abc.com:8000 again doesn't work this time and here is the gunicorn.service in /etc/systemd/system
[Unit]
Description = gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=pi
WorkingDirectory=/home/pi/myvirtualenv_covid19/covid19
ExecStart=/home/pi/myvirtualenv_covid19/covid19env/bin/gunicorn --workers 3 --bind unix:/tmp/covid19.sock covid19.wsgi:application
Restart=always
[Install]
WantedBy=multi-user.target
Curious there is no port to bind to? Maybe I am missing an extra config in my django project???
So secondly getting nginx to see any of this seems an issue, because if i goto
http://webserver2.abc.com:8080/
Gives me a 502 bad gateway. Usually tells me the error in the /var/log/nginx :
2020/10/21 13:33:11 [crit] 1836#1836: *65 connect() to unix:/tmp/covid19.sock failed (2: No such file or directory) while connecting to upstream, client: 10.75.1.245, server: , request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/covid19.sock:/", host: "webserver2.abc.com:8080"
It seems it is running but no sock file in /tmp leads me to believe gunicorn is not running from the systemd/system .service file
So the sock isn't being created it seems, though the gunicorn.socket file does set to have a /run/gunicorn.sock file that is there. Just the /tmp/covid19.sock file is not.
I feel I am close just need a bit of help to connect the dots.
(also my nginx is set to listen on port 8080 but I don't see where I am telling in my gunicorn.service file for it to run on 8080?)
and for completeness my covid19.conf file from sites-available in /etc/nginx/
server {
listen 8080;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/pi/myvirtualenv_covid19/covid19;
}
location / {
include proxy_params;
proxy_pass http://unix:/tmp/covid19.sock;
}
}