I want some help to fix this issue. myproject.wsgi in gunicorn is not recognised.
I created a user flolog with sudo privileges. My project structure is as follows (the first directory i created is flo-log and it contains other directories in d django app):
:~/
flo-log/
account/
logistics/
settings.py
wsgi.py
...
manage.py
...
flologenv/
requirements.txt
Content of gunicorn file is:
How do I fix it? Or is there any resources that can help?
it is difficult to define the problem without your project structure, but seems to me in the working directory you give the path to app folder, but not to root folder. Here are my settings which could help you to configure your wsgi. "conf" is the name of app with settings and asgi wsgi files.
sudo vim /etc/systemd/system/gunicorn.sock
[Unit]
Description=Gunicorn daemon for Django Project
Before=nginx.service
After=network.target
[Service]
WorkingDirectory=/home/www/app/root_folder
ExecStart=/home/www/app/venv/bin/gunicorn --access-logfile - --workers 3 --log-level debug --bind unix:/home/www/app/root_folder/conf.sock conf.wsgi:application
Restart=always
SyslogIdentifier=gunicorn
User=root
Group=www-data
[Install]
WantedBy=multi-user.target
Related
I was trying to run Django in Nginx with the centos7 platform and also I am a newbie to it. After some time, I configured Django in Nginx with the help of the gunicorn service, But suddenly gunicorn service stopped with an unrecognized argument error (WSGI).
enter image description here
and my gunicorn service file:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=user
Group=nginx
WorkingDirectory=/home/websitehg/websites/qatarfactory/qf_project
ExecStart=/home/websitehg/websites/qatarfactory/qf_env/bin/gunicorn --workers 3 --reload true --bind unix:/home/websitehg/websites/qatarfactory/qf_project/qf_project.sock qf_project.wsgi:app
[Install]
WantedBy=multi-user.target
I don't know what's wrong with it
I added threads to it, Problem solved for me
--threads=3
I'm deploying a django project on digital ocean. My project has the following structure:
$/
flo-log/
logistics/
settings.py
wsgi.py
...
manage.py
...
My project gunicorn fille is shown below:
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=flolog
Group=flolog
WorkingDirectory=/home/flolog/flo-log/logistics
ExecStart=/home/flolog/flologenv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
logistics.wsgi:application
[Install]
WantedBy=multi-user.target
I created a user with sudo privilege. Whenever I run sudo systemctl status gunicorn I encountered ModuleNotFoundError: no module named logistics.
And from the details of the error, it's due to the logistics.wsgi: application component of gunicorn service file
The error stated that there's no module called logistics however,I have a directory called logistics which contains the wsgi file. Please how do I fix this error? Why is it that they are telling me logisticsbis not a directory. Better still, how do I set myproject.wsgi section of gunicorn service file properly based on my project structure
I would say just look at your project structure. Remove the flo-log first folder and have Logistics and manage.py inside the home directory of your server as well as your virtual env. The project file "Logistics" should be in the same folder as manage.py inside home.
Hope that helps.
I have a Django app in production, using gunicorn for help. I have a question about the setting EnviromentFile, should I refence the venv path for my project? Is it mandatory? The reason why I'm not adding it in my service file, is because I'm not serving any variables through the env.
/etc/systemd/system/gunicorn.service :
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=user
Group=www-data
WorkingDirectory=/home/user/alpha/project
ExecStart=/home/user/alpha/project/venv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
project.wsgi:application
[Install]
WantedBy=multi-user.target
Do I still need to add, EnviromentFile,to my file above? And if I do, is referencing the activation needed? Like so: EnviromentFile=PATH/TO/venv/bin/activate?
I have the following systemd file at /etc/systemd/system/gunicorn.service
[Unit]
Description=Gunicorn daemon for Django Project
Before=nginx.service
After=network.target
[Service]
WorkingDirectory=/home/serverapp
ExecStart=gunicorn --name=avesoft --bind unix:/home/serverapp/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py WebApp.wsgi:application
Restart=always
SyslogIdentifier=gunicorn
User=root
Group=www-data
[Install]
WantedBy=multi-user.target
When I manually change the directory to /home/serverapp and run gunicorn --name=avesoft --bind unix:/home/serverapp/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py WebApp.wsgi:application everything works fine and Nginx connects to my Django app through Gunicorn.
But by rebooting the server, I get Bad Gateway error that seems Gunicorn has not started working. I don't get what is the reason behind my service file not working.
So I fixed that problem by providing the path for gunicorn :
[Unit]
Description=Gunicorn daemon for Django Project
Before=nginx.service
After=network.target
[Service]
WorkingDirectory=/home/serverapp
ExecStart=/usr/bin/gunicorn --name=avesoft --bind unix:/home/serverapp/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py WebApp.wsgi:application
Restart=always
SyslogIdentifier=gunicorn
User=root
Group=www-data
[Install]
WantedBy=multi-user.target
I have two django projects running on different ports in same ec2 instance, One I have configured with gunicorn system as follows by creating gunicorn.service file at /etc/systemd/system/ which is working awesome if I run the command systemctl start gunicorn. Now I want to run another proect, how can I configure it, currently I am running that using gunicorn command /usr/local/bin/gunicorn --graceful-timeout 30 --bind 0.0.0.0:8690 projectFile.wsgi:application --daemon, Can I add same in gunicorn.service itself. How do I configure multiple projects in gunicorn systemd?
gunicron.service file -
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
PIDFile=/tmp/gunicorn.pid
LogFile=/tmp/lgunicorn.log
User=root
Group=www-data
WorkingDirectory=/home/ubuntu/website/UniservedWebsite
ExecStart = /usr/local/bin/gunicorn --workers 2 --graceful-timeout 30 --bind 0.0.0.0:8134 UniservedWebsite.wsgi:application
[Install]
WantedBy=multi-user.target
Just create two .service file, and start them separately...