我正在尝试设置DigitalOcean Droplet来容纳Django应用程序,而我正在遵循以下概述:https://simpleisbetterthancomplex.com/tutorial/2016/10/14/how-to-deploy-to-digital-ocean.html
当我通过python manage.py runserver 0.0.0.0:8000
但是,一旦通过sudo supervisorctl restart all
启动了应用程序并运行了sudo supervisorctl status
,我就明白了,但是当我到达正确的URL时,该应用程序将无法工作:
exactestate@ExactEstateDroplet:~$ sudo supervisorctl status ExactEstate
ExactEstate RUNNING pid 3071, uptime 0:00:19
有人可以帮忙吗?
这是我的目录结构:
exactestate@ExactEstateDroplet:~$ cd ../
exactestate@ExactEstateDroplet:/home$ cd ../
exactestate@ExactEstateDroplet:/$ ls
bin dev home initrd.img.old lib64 media opt root sbin srv tmp var vmlinuz.old
boot etc initrd.img lib lost+found mnt proc run snap sys usr vmlinuz
exactestate@ExactEstateDroplet:/$ ^C
exactestate@ExactEstateDroplet:/$ cd home
exactestate@ExactEstateDroplet:/home$ ls
exactestate
exactestate@ExactEstateDroplet:/home$ cd exactestate
exactestate@ExactEstateDroplet:~$ ls
ExactEstate bin include lib local logs run share
exactestate@ExactEstateDroplet:~$ cd bin
exactestate@ExactEstateDroplet:~/bin$ ls
activate activate.fish easy_install gunicorn_start pip2 python python2 wheel
activate.csh activate_this.py easy_install-2.7 pip pip2.7 python-config python2.7
exactestate@ExactEstateDroplet:~/bin$ cd ../
exactestate@ExactEstateDroplet:~$ cd ExactEstate
exactestate@ExactEstateDroplet:~/ExactEstate$ ls
ExactEstate app.yaml forms interface_login interface_management interface_resident interface_security objects requirements.txt utils
README.md cron.yaml interface_admin interface_maintenance interface_onsite interface_root manage.py objects_client templates
exactestate@ExactEstateDroplet:~/ExactEstate$ ExactEstate is my Django Project Directory
这是我的gunicorn_start文件
#!/bin/bash
NAME="ExactEstate"
DIR=/home/exactestate/ExactEstate
USER=exactestate
GROUP=exactestate
WORKERS=3
BIND=unix:/home/exactestate/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=ExactEstate.settings
DJANGO_WSGI_MODULE=ExactEstate.wsgi
LOG_LEVEL=error
cd $DIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH
exec ../bin/gunicorn_start ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $WORKERS \
--user=$USER \
--group=$GROUP \
--bind=$BIND \
--log-level=$LOG_LEVEL \
--log-file=-
这是我的主管配置
[program:ExactEstate]
command=/home/exactestate/bin/gunicorn_start
user=exactestate
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/exactestate/logs/gunicorn-error.log
Nginix配置
upstream app_server {
server unix:/home/exactestate/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
# add here the ip address of your server
# or a domain pointing to that ip (like example.com or www.example.com)
server_name 157.230.230.54;
keepalive_timeout 5;
client_max_body_size 4G;
access_log /home/exactestate/logs/nginx-access.log;
error_log /home/exactestate/logs/nginx-error.log;
location /static/ {
alias /home/exactestate/static/;
}
# checks for static file, if not found proxy to app
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
最新的gunicorn-error.log
/home/exactestate/ExactEstate/../bin/gunicorn_start: line 16:
/home/exactestate/ExactEstate/../bin/gunicorn_start: Argument list too long
/home/exactestate/ExactEstate/../bin/gunicorn_start: line 16: /
/home/exactestate/ExactEstate/../bin/gunicorn_start: Success
答案 0 :(得分:0)
我不知道您为什么要进行如此复杂的设置,这是我的帐户网站conf,它的工作原理很简单:
format2 = workbook.add_format({'num_format': '0.0%'})
worksheet.set_column('D:D', 40, format2)
答案 1 :(得分:0)
可能您的gunicorn_start脚本有语法错误。我的建议是直接在主管.conf上使用较小的命令行。
在nginx.conf上:
1)尝试使用有效的URL更改Servername参数,例如:
exactestate.com
2)将袜子配置更改为TCP:
upstream gunicorn_panel {
# For a TCP configuration:
server 127.0.0.1:9000 fail_timeout=0; }
server {
listen 8080;
在supervisor.conf上,不要使用gunicorn_start文件,而是尝试直接在命令变量上写所有命令:
[program:powerpanel]
command=/home/web/.virtualenvs/accounting/bin/gunicorn powerpanel.wsgi -b 127.0.0.1:9000 -w1 --pythonpath=/home/exactestate/ExactEstate --error-logfile=/home/exactestate/logs/gunicorn-error.log
user=webapp
autostart=true
autorestart=unexpected
startsecs=1
startretries=3
redirect_stderr=true